餐饮油烟智能监测与监管一体化平台
feiyu02
6 天以前 ccc970e575ef3f3e5c67af8da210263f4ac549f9
src/components/search-option/FYOptionTopTask.vue
@@ -6,76 +6,68 @@
      :placeholder="label"
      style="width: 260px"
    >
      <el-option
        v-for="s in filtedBeforeTask"
        :key="s.value"
        :label="s.label"
        :value="s.value"
      />
      <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 taskApi from '@/api/fysp/taskApi'
import dayjs from 'dayjs'
export default {
  props: {
    label: {
      type: String,
      default: '总任务'
      default: '总任务',
    },
    // 返回结果
    value: Object,
    // 是否默认返回初始选项
    initValue: {
      type: Boolean,
      default: true
      default: true,
    },
    // form表单绑定属性名
    prop: {
      type: String,
      default: 'topTaskId'
      default: 'topTaskId',
    },
    // 选项筛选条件,筛选某任务之前的相同行政区划内的任务
    beforeTask: {
      type: Object,
      default: () => {
        return {};
      }
    }
        return {}
      },
    },
  },
  emits: ['update:value'],
  data() {
    return {
      selected: {},
      topTasks: []
    };
      topTasks: [],
    }
  },
  computed: {
    // 选择框中使用顶层任务id作为选项值
    formatedValue() {
      return this.value?.tguid;
      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)
        );
      });
          (!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);
        this.handleChange(filteredTasks[0]?.value)
      }
      return filteredTasks;
    }
      return filteredTasks
    },
  },
  methods: {
    //获取查询条件
@@ -85,25 +77,29 @@
          return {
            value: r.tguid,
            label: r.name,
            data: r
          };
        });
        this.topTasks = list;
            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);
          this.handleChange(list[0].value)
        }
      });
      })
    },
    //查询子任务统计信息
    handleChange(value) {
      const task = this.topTasks.find((t) => t.data.tguid == value);
      const param = task ? task.data : {};
      const task = this.topTasks.find((t) => t.data.tguid == value)
      const param = task ? task.data : {}
      this.$emit('update:value', param);
    }
      this.$emit('update:value', param)
    },
  },
  mounted() {
    this.getOptions();
  }
};
    this.getOptions()
  },
}
</script>