feiyu02
2025-07-21 5be9679fb4288936b576cf3d1f1548af1c4151b8
src/views/fysp/task/components/CompSubTaskSelect.vue
@@ -70,15 +70,12 @@
/**
 * 巡查子任务创建
 */
import { ref, reactive, watch, computed, onMounted } from 'vue';
import { ref, reactive, watch, computed, onMounted, inject } from 'vue';
import { ElMessageBox, ElNotification, ElMessage } from 'element-plus';
import taskApi from '@/api/fysp/taskApi';
import TaskProxy from '../TaskProxy';
onMounted(() => {
  // if (props.height) {
  //   scrollHeight.value =
  // }
});
// const topTask = inject('topTask');
const props = defineProps({
  // 子任务集合
@@ -91,7 +88,7 @@
  dayTask: Object
});
const emit = defineEmits(['delete']);
const emit = defineEmits(['submit', 'delete']);
const scrollHeight = ref('14vh');
@@ -120,10 +117,17 @@
    fail('未选择监管场景');
  } else {
    success();
    // 将任务执行人格式化并传递
    const param = TaskProxy.getExecutors(v.value.executor, executors.value);
    emit('submit', param);
  }
}
/************************* 任务执行人下拉选框 *******************************/
// onMounted(() => {
//   getExecutors(topTask.value);
// });
const executors = ref([]);
// 是否全选
const checkAll = ref(false);
@@ -138,36 +142,46 @@
    formInfo.value.executor = [];
  }
}
function getExecutors(t) {
  const ids = t.executorguids.split('#');
  const userNames = t.executorusernames.split('#');
  const realNames = t.executorrealnames.split('#');
  const list = [];
  ids.forEach((e, i) => {
    if (i < userNames.length && i < realNames.length) {
      list.push({
        label: realNames[i],
        value: e,
        data: {
          id: e,
          userName: userNames[i],
          realName: realNames[i]
        }
      });
    }
  });
  executors.value = list;
}
// watch(topTask, (nV, oV) => {
//   if (nV != oV) {
//     getExecutors(nV);
//   }
// });
watch(
  () => props.dayTask,
  (nV, oV) => {
    if (nV != oV) {
      taskApi.fetchTaskById(nV.guid).then((res) => {
        const ids = res.executorguids.split('#');
        const userNames = res.executorusernames.split('#');
        const realNames = res.executorrealnames.split('#');
        const list = [];
        ids.forEach((e, i) => {
          if (i < userNames.length && i < realNames.length) {
            list.push({
              label: realNames[i],
              value: e,
              data: {
                id: e,
                userName: userNames[i],
                realName: realNames[i]
              }
            });
          }
        });
        executors.value = list;
        getExecutors(res);
      });
    }
  },
  { immediate: true }
);
//
watch(
  () => formInfo.value.executor,
  (val) => {