| | |
| | | <script setup lang="ts"> |
| | | import { computed, ref, watch } from 'vue'; |
| | | import { jsonClone } from '~/packages/utils'; |
| | | import { fetchCreateHoisterData, fetchUpdateHoisterData } from '@/service/api/analy/hoister-data'; |
| | | import { useFormRules, useNaiveForm } from '@/hooks/common/form'; |
| | | import { $t } from '@/locales'; |
| | | import { jsonClone } from '~/packages/utils'; |
| | | |
| | | defineOptions({ |
| | | name: 'HoisterDataOperateDrawer' |
| | |
| | | |
| | | function createDefaultModel(): Model { |
| | | return { |
| | | time: null, |
| | | key: '', |
| | | online: null, |
| | | qty: null, |
| | | tState1: null, |
| | | tState2: null, |
| | | tState3: null, |
| | | tState4: null, |
| | | tState5: null, |
| | | tState6: null, |
| | | tState7: null, |
| | | tState8: null, |
| | | tState9: null, |
| | | tState10: null, |
| | | tState11: null, |
| | | tState12: null, |
| | | pState1: null, |
| | | pState2: null, |
| | | pState3: null, |
| | | pState4: null, |
| | | tQty1: null, |
| | | tQty2: null, |
| | | tQty3: null, |
| | | tQty4: null, |
| | | tQty5: null, |
| | | tQty6: null, |
| | | tQty7: null, |
| | | tQty8: null, |
| | | tQty9: null, |
| | | tQty10: null, |
| | | tQty11: null, |
| | | tQty12: null, |
| | | pQty1: null, |
| | | pQty2: null, |
| | | pQty3: null, |
| | | pQty4: null, |
| | | shift: null, |
| | | equNo: null, |
| | | remark: '' |
| | | time: null, |
| | | key: '', |
| | | online: null, |
| | | qty: null, |
| | | tState1: null, |
| | | tState2: null, |
| | | tState3: null, |
| | | tState4: null, |
| | | tState5: null, |
| | | tState6: null, |
| | | tState7: null, |
| | | tState8: null, |
| | | tState9: null, |
| | | tState10: null, |
| | | tState11: null, |
| | | tState12: null, |
| | | pState1: null, |
| | | pState2: null, |
| | | pState3: null, |
| | | pState4: null, |
| | | tQty1: null, |
| | | tQty2: null, |
| | | tQty3: null, |
| | | tQty4: null, |
| | | tQty5: null, |
| | | tQty6: null, |
| | | tQty7: null, |
| | | tQty8: null, |
| | | tQty9: null, |
| | | tQty10: null, |
| | | tQty11: null, |
| | | tQty12: null, |
| | | pQty1: null, |
| | | pQty2: null, |
| | | pQty3: null, |
| | | pQty4: null, |
| | | shift: null, |
| | | equNo: null, |
| | | remark: '' |
| | | }; |
| | | } |
| | | |
| | | type RuleKey = Extract< |
| | | keyof Model, |
| | | | 'time' |
| | | | 'key' |
| | | >; |
| | | type RuleKey = Extract<keyof Model, 'time' | 'key'>; |
| | | |
| | | const rules: Record<RuleKey, App.Global.FormRule> = { |
| | | time: createRequiredRule('时间不能为空'), |
| | | key: createRequiredRule('key不能为空'), |
| | | key: createRequiredRule('key不能为空') |
| | | }; |
| | | |
| | | function handleUpdateModelWhenEdit() { |
| | |
| | | async function handleSubmit() { |
| | | await validate(); |
| | | |
| | | const { time, key, online, qty, tState1, tState2, tState3, tState4, tState5, tState6, tState7, tState8, tState9, tState10, tState11, tState12, pState1, pState2, pState3, pState4, tQty1, tQty2, tQty3, tQty4, tQty5, tQty6, tQty7, tQty8, tQty9, tQty10, tQty11, tQty12, pQty1, pQty2, pQty3, pQty4, shift, equNo, remark } = model.value; |
| | | const { |
| | | time, |
| | | key, |
| | | online, |
| | | qty, |
| | | tState1, |
| | | tState2, |
| | | tState3, |
| | | tState4, |
| | | tState5, |
| | | tState6, |
| | | tState7, |
| | | tState8, |
| | | tState9, |
| | | tState10, |
| | | tState11, |
| | | tState12, |
| | | pState1, |
| | | pState2, |
| | | pState3, |
| | | pState4, |
| | | tQty1, |
| | | tQty2, |
| | | tQty3, |
| | | tQty4, |
| | | tQty5, |
| | | tQty6, |
| | | tQty7, |
| | | tQty8, |
| | | tQty9, |
| | | tQty10, |
| | | tQty11, |
| | | tQty12, |
| | | pQty1, |
| | | pQty2, |
| | | pQty3, |
| | | pQty4, |
| | | shift, |
| | | equNo, |
| | | remark |
| | | } = model.value; |
| | | |
| | | // request |
| | | if (props.operateType === 'add') { |
| | | const { error } = await fetchCreateHoisterData({ time, key, online, qty, tState1, tState2, tState3, tState4, tState5, tState6, tState7, tState8, tState9, tState10, tState11, tState12, pState1, pState2, pState3, pState4, tQty1, tQty2, tQty3, tQty4, tQty5, tQty6, tQty7, tQty8, tQty9, tQty10, tQty11, tQty12, pQty1, pQty2, pQty3, pQty4, shift, equNo, remark }); |
| | | const { error } = await fetchCreateHoisterData({ |
| | | time, |
| | | key, |
| | | online, |
| | | qty, |
| | | tState1, |
| | | tState2, |
| | | tState3, |
| | | tState4, |
| | | tState5, |
| | | tState6, |
| | | tState7, |
| | | tState8, |
| | | tState9, |
| | | tState10, |
| | | tState11, |
| | | tState12, |
| | | pState1, |
| | | pState2, |
| | | pState3, |
| | | pState4, |
| | | tQty1, |
| | | tQty2, |
| | | tQty3, |
| | | tQty4, |
| | | tQty5, |
| | | tQty6, |
| | | tQty7, |
| | | tQty8, |
| | | tQty9, |
| | | tQty10, |
| | | tQty11, |
| | | tQty12, |
| | | pQty1, |
| | | pQty2, |
| | | pQty3, |
| | | pQty4, |
| | | shift, |
| | | equNo, |
| | | remark |
| | | }); |
| | | if (error) return; |
| | | } |
| | | |
| | | if (props.operateType === 'edit') { |
| | | const { error } = await fetchUpdateHoisterData({ time, key, online, qty, tState1, tState2, tState3, tState4, tState5, tState6, tState7, tState8, tState9, tState10, tState11, tState12, pState1, pState2, pState3, pState4, tQty1, tQty2, tQty3, tQty4, tQty5, tQty6, tQty7, tQty8, tQty9, tQty10, tQty11, tQty12, pQty1, pQty2, pQty3, pQty4, shift, equNo, remark }); |
| | | const { error } = await fetchUpdateHoisterData({ |
| | | time, |
| | | key, |
| | | online, |
| | | qty, |
| | | tState1, |
| | | tState2, |
| | | tState3, |
| | | tState4, |
| | | tState5, |
| | | tState6, |
| | | tState7, |
| | | tState8, |
| | | tState9, |
| | | tState10, |
| | | tState11, |
| | | tState12, |
| | | pState1, |
| | | pState2, |
| | | pState3, |
| | | pState4, |
| | | tQty1, |
| | | tQty2, |
| | | tQty3, |
| | | tQty4, |
| | | tQty5, |
| | | tQty6, |
| | | tQty7, |
| | | tQty8, |
| | | tQty9, |
| | | tQty10, |
| | | tQty11, |
| | | tQty12, |
| | | pQty1, |
| | | pQty2, |
| | | pQty3, |
| | | pQty4, |
| | | shift, |
| | | equNo, |
| | | remark |
| | | }); |
| | | if (error) return; |
| | | } |
| | | |
| | |
| | | /> |
| | | </NFormItem> |
| | | <NFormItem label="key" path="key"> |
| | | <NInput |
| | | v-model:value="model.key" |
| | | :rows="3" |
| | | type="textarea" |
| | | placeholder="请输入key" |
| | | /> |
| | | <NInput v-model:value="model.key" :rows="3" type="textarea" placeholder="请输入key" /> |
| | | </NFormItem> |
| | | <NFormItem label="网络状态 0异常,1正常" path="online"> |
| | | <NInput v-model:value="model.online" placeholder="请输入网络状态 0异常,1正常" /> |