<script setup lang="ts">
|
import { toRaw } from 'vue';
|
import { jsonClone } from '@sa/utils';
|
import { useNaiveForm } from '@/hooks/common/form';
|
import { $t } from '@/locales';
|
|
defineOptions({
|
name: 'StdSearch'
|
});
|
|
interface Emits {
|
(e: 'search'): void;
|
}
|
|
const emit = defineEmits<Emits>();
|
|
const { formRef, validate, restoreValidation } = useNaiveForm();
|
|
const model = defineModel<Api.Qm.StdSearchParams>('model', { required: true });
|
|
const defaultModel = jsonClone(toRaw(model.value));
|
|
// 判定类型选项:0-手动判定 1-上下限判定 2-平均值判定 3-SD值判定 4-CV值判定 5-超标数判定
|
const typOptions = [
|
{ label: '手动判定', value: 0 },
|
{ label: '上下限判定', value: 1 },
|
{ label: '平均值判定', value: 2 },
|
{ label: 'SD值判定', value: 3 },
|
{ label: 'CV值判定', value: 4 },
|
{ label: '超标数判定', value: 5 }
|
];
|
|
// 物料类型选项:0-成品 1-辅料
|
const categoryOptions = [
|
{ label: '成品', value: 0 },
|
{ label: '辅料', value: 1 }
|
];
|
|
function resetModel() {
|
Object.assign(model.value, defaultModel);
|
}
|
|
async function reset() {
|
await restoreValidation();
|
resetModel();
|
emit('search');
|
}
|
|
async function search() {
|
await validate();
|
emit('search');
|
}
|
</script>
|
|
<template>
|
<NCard :bordered="false" size="small" class="card-wrapper">
|
<NCollapse>
|
<NCollapseItem :title="$t('common.search')" name="qm-std-search">
|
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
|
<NGrid responsive="screen" item-responsive>
|
<NFormItemGi span="24 s:12 m:6" label="规程代码" label-width="auto" path="stdCode" class="pr-24px">
|
<NInput v-model:value="model.stdCode" placeholder="请输入规程代码" />
|
</NFormItemGi>
|
<NFormItemGi span="24 s:12 m:6" label="规程名称" label-width="auto" path="stdName" class="pr-24px">
|
<NInput v-model:value="model.stdName" placeholder="请输入规程名称" />
|
</NFormItemGi>
|
<NFormItemGi span="24 s:12 m:6" label="判定类型" label-width="auto" path="typ" class="pr-24px">
|
<NSelect v-model:value="model.typ" :options="typOptions" placeholder="请选择判定类型" clearable />
|
</NFormItemGi>
|
<NFormItemGi span="24 s:12 m:6" label="物料类型" label-width="auto" path="category" class="pr-24px">
|
<NSelect v-model:value="model.category" :options="categoryOptions" placeholder="请选择物料类型" clearable />
|
</NFormItemGi>
|
<NFormItemGi :show-feedback="false" span="24" class="pr-24px">
|
<NSpace class="w-full" justify="end">
|
<NButton @click="reset">
|
<template #icon>
|
<icon-ic-round-refresh class="text-icon" />
|
</template>
|
{{ $t('common.reset') }}
|
</NButton>
|
<NButton type="primary" ghost @click="search">
|
<template #icon>
|
<icon-ic-round-search class="text-icon" />
|
</template>
|
{{ $t('common.search') }}
|
</NButton>
|
</NSpace>
|
</NFormItemGi>
|
</NGrid>
|
</NForm>
|
</NCollapseItem>
|
</NCollapse>
|
</NCard>
|
</template>
|
|
<style scoped></style>
|