|
|
@ -29,7 +29,7 @@ export function useEnvironmentName( |
|
|
|
let environmentList = [] as IEnvironmentNameOption[] |
|
|
|
let environmentList = [] as IEnvironmentNameOption[] |
|
|
|
const options = ref([] as IEnvironmentNameOption[]) |
|
|
|
const options = ref([] as IEnvironmentNameOption[]) |
|
|
|
const loading = ref(false) |
|
|
|
const loading = ref(false) |
|
|
|
const value = ref() |
|
|
|
let mounted = false |
|
|
|
|
|
|
|
|
|
|
|
const getEnvironmentList = async () => { |
|
|
|
const getEnvironmentList = async () => { |
|
|
|
if (loading.value) return |
|
|
|
if (loading.value) return |
|
|
@ -46,6 +46,11 @@ export function useEnvironmentName( |
|
|
|
filterByWorkerGroup(option) |
|
|
|
filterByWorkerGroup(option) |
|
|
|
) |
|
|
|
) |
|
|
|
loading.value = false |
|
|
|
loading.value = false |
|
|
|
|
|
|
|
if (options.value.length === 0) { |
|
|
|
|
|
|
|
model.environmentCode = null |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
isCreate && (model.environmentCode = options.value[0].value) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const filterByWorkerGroup = (option: IEnvironmentNameOption) => { |
|
|
|
const filterByWorkerGroup = (option: IEnvironmentNameOption) => { |
|
|
@ -54,28 +59,21 @@ export function useEnvironmentName( |
|
|
|
return option.workerGroups.indexOf(model.workerGroup) !== -1 |
|
|
|
return option.workerGroups.indexOf(model.workerGroup) !== -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
|
|
|
() => options.value.length, |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
if (isCreate && options.value.length === 1 && !value.value) { |
|
|
|
|
|
|
|
model.environmentCode = options.value[0].value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (options.value.length === 0) model.environmentCode = null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
watch( |
|
|
|
() => model.workerGroup, |
|
|
|
() => model.workerGroup, |
|
|
|
() => { |
|
|
|
() => { |
|
|
|
if (!model.workerGroup) return |
|
|
|
if (!model.workerGroup || !mounted) return |
|
|
|
options.value = environmentList.filter((option: IEnvironmentNameOption) => |
|
|
|
options.value = environmentList.filter((option: IEnvironmentNameOption) => |
|
|
|
filterByWorkerGroup(option) |
|
|
|
filterByWorkerGroup(option) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
model.environmentCode = |
|
|
|
|
|
|
|
options.value.length === 0 ? null : options.value[0].value |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
onMounted(async () => { |
|
|
|
getEnvironmentList() |
|
|
|
await getEnvironmentList() |
|
|
|
|
|
|
|
mounted = true |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|