<div class="protect-group-nat__select">…
- User
<div v-if="type === 2"> <el-input v-model.number="threadscount" type="number" style="padding-top: 5px;" :min="1" :max="8" :placeholder="$t('set.configuration.advanced.threads.placeholder')" @keydown.enter.prevent="" @change="validateThreadCount" /> </div> </div> const threadscount = ref(0) const threadsType = ref(0) const threadsOptions = computed(() => [ { label: t('set.configuration.advanced.threads.auto').toString(), value: 0 }, { label: t('set.configuration.advanced.threads.max').toString(), value: 1 }, { label: t('set.configuration.advanced.threads.num').toString(), value: 2 } ]) const calculateAutoThreads = (cpuCount: number) => { return Math.max(1, Math.min(8, Math.floor(cpuCount * 0.5))) } const calculateMaxThreads = (cpuCount: number) => { return Math.min(8, cpuCount) } const updateThreadsCount = (type: number) => { for (const idx in unref(pairsForm)) { let updatedCount = unref(pairsForm)[idx].threads.threadscount if (type === 0) { // auto updatedCount = calculateAutoThreads(4) } else if (type === 1) { // max updatedCount = calculateMaxThreads(4) } else if (type === 2) { // num updatedCount = Math.min(unref(pairsForm)[idx].threads.threadscount, 4) } unref(pairsForm)[idx].threads.threadscount = updatedCount } }const pairsForm = ref<Record<string, NatConfig>>({})
const setMassData = () => { for (const idx in unref(pairsForm)) { unref(pairsForm)[idx].threads.threadscount = unref(threadscount) unref(pairsForm)[idx].threads.type = unref(threadsType) } }как здесь правильно отправлять данные?
- Assistant
- User
нужно чтобы threadscount определялся верно по этим условиям const updateThreadsCount = (type: number) => { for (const idx in unref(pairsForm)) { let updatedCount = unref(pairsForm)[idx].threads.threadscount if (type === 0) { // auto updatedCount = calculateAutoThreads(4) } else if (type === 1) { // max updatedCount = calculateMaxThreads(4) } else if (type === 2) { // num updatedCount = Math.min(unref(pairsForm)[idx].threads.threadscount, 4) }
unref(pairsForm)[idx].threads.threadscount = updatedCount } } const calculateAutoThreads = (cpuCount: number) => { return Math.max(1, Math.min(8, Math.floor(cpuCount * 0.5))) } const calculateMaxThreads = (cpuCount: number) => { return Math.min(8, cpuCount) } - Assistant
- User
columnHelper.display({ id: 'threads', header: t('set.configuration.advanced.threads.title').toString(), cell: ({ row: { original } }) => h('el-select', { on: { change: (val) => { pairsFormModel.value[original.id].threads.type } }, style: 'width: 230px;', props: { value: unref(pairsFormModel)[original.id].threads.type, placeholder: t('set.configuration.advanced.threads.select') } }, unref(threadsOptions).map(option => h('el-option', { props: { key: option.value, label: option.label, value: option.value } } )) ), minSize: 210 }),
если el-option === 2, то надо дополнительно отображать <el-input v-model.number="unref(pairsFormModel)[original.id].threads.threadscount" type="number" style="padding-top: 5px;" :min="1" :max="8" :placeholder="$t('set.configuration.advanced.threads.placeholder')" @keydown.enter.prevent="" @change="validateThreadCount" />
- Assistant