| | |
| | | <script setup lang="ts"> |
| | | import { computed, ref, watch } from 'vue'; |
| | | import { jsonClone } from '@sa/utils'; |
| | | import { |
| | | fetchCreateCheckitem, |
| | | fetchGetRid, |
| | | fetchUpdateCheckitem |
| | | } from '@/service/api/qm/checkitem'; |
| | | import { fetchCreateCheckitem, fetchGetRid, fetchUpdateCheckitem } from '@/service/api/qm/checkitem'; |
| | | import { fetchGetInstrumentList } from '@/service/api/md/instrument'; |
| | | import { useFormRules, useNaiveForm } from '@/hooks/common/form'; |
| | | import { $t } from '@/locales'; |
| | |
| | | fetchInstrumentOptions(query); |
| | | } |
| | | |
| | | |
| | | function createDefaultModel(): Model { |
| | | return { |
| | | id: '', |
| | | itemCode: '', |
| | | itemName: '', |
| | | unit: '', |
| | | enable: 1, |
| | | del: 0, |
| | | itemDes: '', |
| | | stdCode: '', |
| | | instrumentDes: '', |
| | | location: '', |
| | | checkLevel: '', |
| | | ismix: null, |
| | | rid: null, |
| | | category: null, |
| | | instrumentCode: '', |
| | | score: null |
| | | id: '', |
| | | itemCode: '', |
| | | itemName: '', |
| | | unit: '', |
| | | enable: 1, |
| | | del: 0, |
| | | itemDes: '', |
| | | stdCode: '', |
| | | instrumentDes: '', |
| | | location: '', |
| | | checkLevel: '', |
| | | ismix: null, |
| | | rid: null, |
| | | category: null, |
| | | instrumentCode: '', |
| | | score: null |
| | | }; |
| | | } |
| | | |
| | | type RuleKey = Extract< |
| | | keyof Model, |
| | | | 'id' |
| | | >; |
| | | type RuleKey = Extract<keyof Model, 'id'>; |
| | | |
| | | const rules: Record<RuleKey, App.Global.FormRule> = { |
| | | id: createRequiredRule('编码不能为空'), |
| | | id: createRequiredRule('编码不能为空') |
| | | }; |
| | | |
| | | async function handleUpdateModelWhenEdit() { |
| | |
| | | async function handleSubmit() { |
| | | await validate(); |
| | | |
| | | const { id, itemCode, itemName, unit, enable, del, itemDes, stdCode, instrumentDes, location, checkLevel, ismix, rid, category, instrumentCode, score } = model.value; |
| | | const { |
| | | id, |
| | | itemCode, |
| | | itemName, |
| | | unit, |
| | | enable, |
| | | del, |
| | | itemDes, |
| | | stdCode, |
| | | instrumentDes, |
| | | location, |
| | | checkLevel, |
| | | ismix, |
| | | rid, |
| | | category, |
| | | instrumentCode, |
| | | score |
| | | } = model.value; |
| | | |
| | | // request |
| | | if (props.operateType === 'add') { |
| | | const payload = { itemCode, itemName, unit, enable, del, itemDes, stdCode, instrumentDes, location, checkLevel, ismix, rid, category, instrumentCode, score }; |
| | | const payload = { |
| | | itemCode, |
| | | itemName, |
| | | unit, |
| | | enable, |
| | | del, |
| | | itemDes, |
| | | stdCode, |
| | | instrumentDes, |
| | | location, |
| | | checkLevel, |
| | | ismix, |
| | | rid, |
| | | category, |
| | | instrumentCode, |
| | | score |
| | | }; |
| | | const { error } = await fetchCreateCheckitem(payload); |
| | | if (error) return; |
| | | } |
| | | |
| | | if (props.operateType === 'edit') { |
| | | const payload = { id, itemCode, itemName, unit, enable, del, itemDes, stdCode, instrumentDes, location, checkLevel, ismix, rid, category, instrumentCode, score }; |
| | | const payload = { |
| | | id, |
| | | itemCode, |
| | | itemName, |
| | | unit, |
| | | enable, |
| | | del, |
| | | itemDes, |
| | | stdCode, |
| | | instrumentDes, |
| | | location, |
| | | checkLevel, |
| | | ismix, |
| | | rid, |
| | | category, |
| | | instrumentCode, |
| | | score |
| | | }; |
| | | const { error } = await fetchUpdateCheckitem(payload); |
| | | if (error) return; |
| | | } |