您可以使用watch函数来监听yncf.cfDoctor的变化,并在变化时获取对应的doctor的sectionId,并将sectionId赋值给yncf.cfSecid。以下是实现的代码示例:

import { defineComponent, ref, watch } from 'vue';

export default defineComponent({
  setup() {
    const yncf = ref({
      cfDoctor: null, // 初始化cfDoctor
      cfSecid: null // 初始化cfSecid
    });

    const doctors = ref(null);
    const sections = ref(null);

    const fetchData = async () => {
      try {
        doctors.value = await defHttp.get({ url: '/workstation/ylEmployee/getDoctors' });
        sections.value = await defHttp.get({ url: '/workstation/ylSection/getSections' });
      } catch (error) {
        console.error(error);
      }
    };

    watch(yncf.cfDoctor, (newDoctorId) => {
      // 获取对应doctor的sectionId
      const doctor = doctors.value.find((item) => item.id === newDoctorId);
      if (doctor) {
        yncf.cfSecid = doctor.sectionId;
      }
    });

    fetchData();

    return {
      yncf,
      doctors,
      sections
    };
  }
});

在上述代码中,我们使用了watch函数来监听yncf.cfDoctor的变化。当yncf.cfDoctor发生变化时,会执行回调函数,并在回调函数中根据newDoctorId获取对应的doctor的sectionId,并将其赋值给yncf.cfSecid

span 医生: a-select v-modelvalue=yncfcfDoctor show-search filter-option=changeOption style=width 150px a-select-option v-for=item in doctors key=itempym value=itemid itemem

原文地址: https://www.cveoy.top/t/topic/iQFJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录