| | |
| | | <script setup lang="ts"> |
| | | import { toRaw } from 'vue'; |
| | | import { onMounted, ref, toRaw, watch } from 'vue'; |
| | | import { jsonClone } from '@sa/utils'; |
| | | import { fetchGetMatList } from '@/service/api/md/mat'; |
| | | import { useNaiveForm } from '@/hooks/common/form'; |
| | | import { $t } from '@/locales'; |
| | | |
| | |
| | | const model = defineModel<Api.Qm.JudgeSearchParams>('model', { required: true }); |
| | | |
| | | const defaultModel = jsonClone(toRaw(model.value)); |
| | | |
| | | const matOptions = ref<CommonType.Option[]>([]); |
| | | |
| | | async function getMatOptions() { |
| | | if (model.value.category !== 0) { |
| | | matOptions.value = []; |
| | | model.value.matName = null; |
| | | model.value.matCode = null; |
| | | return; |
| | | } |
| | | const { data } = await fetchGetMatList({ tid: 1, pageSize: 1000 }); |
| | | if (data) { |
| | | matOptions.value = data.rows.map(item => ({ |
| | | label: item.name, |
| | | value: item.code |
| | | })); |
| | | } |
| | | } |
| | | |
| | | watch( |
| | | () => model.value.category, |
| | | newVal => { |
| | | if (newVal === 0) { |
| | | getMatOptions(); |
| | | } else { |
| | | matOptions.value = []; |
| | | model.value.matName = null; |
| | | model.value.matCode = null; |
| | | } |
| | | } |
| | | ); |
| | | |
| | | onMounted(() => { |
| | | if (model.value.category === 0) { |
| | | getMatOptions(); |
| | | } |
| | | }); |
| | | |
| | | function resetModel() { |
| | | Object.assign(model.value, defaultModel); |
| | |
| | | /> |
| | | </NFormItemGi> |
| | | |
| | | <NFormItemGi span="24 s:12 m:6" label="物料牌号代码" label-width="auto" path="matCode" class="pr-24px"> |
| | | <NInput v-model:value="model.matCode" placeholder="请输入物料牌号代码" /> |
| | | </NFormItemGi> |
| | | <NFormItemGi span="24 s:12 m:6" label="物料牌号" label-width="auto" path="matName" class="pr-24px"> |
| | | <NInput v-model:value="model.matName" placeholder="请输入物料牌号" /> |
| | | <NFormItemGi span="24 s:12 m:6" label="物料牌号" label-width="auto" path="matCode" class="pr-24px"> |
| | | <NSelect |
| | | v-model:value="model.matCode" |
| | | :options="matOptions" |
| | | placeholder="请选择物料牌号" |
| | | :disabled="model.category !== 0" |
| | | clearable |
| | | filterable |
| | | /> |
| | | </NFormItemGi> |
| | | <NFormItemGi span="24 s:12 m:6" label="判定名称" label-width="auto" path="judgeName" class="pr-24px"> |
| | | <NInput v-model:value="model.judgeName" placeholder="请输入判定名称" /> |