| | |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useFormSchema } from '../../../pro/feedback/data'; |
| | | import FeedbackParamFields from '../../../pro/feedback/components/FeedbackParamFields.vue'; |
| | | |
| | | defineOptions({ name: 'WorkbenchFeedbackTab' }); |
| | | |
| | |
| | | const feedbackId = ref<number>(); |
| | | const feedbackStatus = ref<number>(); |
| | | const originalSnapshot = ref(''); |
| | | const paramFields = ref<InstanceType<typeof FeedbackParamFields>>(); |
| | | const paramSnapshot = ref<string>(); |
| | | const paramRenderKey = ref(0); |
| | | |
| | | const isEditable = computed(() => |
| | | ['create', 'submit', 'update'].includes(formType.value), |
| | |
| | | } |
| | | } |
| | | |
| | | async function getAlignedData() { |
| | | async function getAlignedData(includeParams = true) { |
| | | const data = (await formApi.getValues()) as any; |
| | | // 新建时不能携带上一张报工单残留的 id,否则后端按主键插入会冲突 |
| | | if (formType.value === 'create') { |
| | | delete data.id; |
| | | } |
| | | alignQuantity(data); |
| | | if (includeParams) data.paramValues = paramFields.value?.getValues(); |
| | | return data; |
| | | } |
| | | |
| | |
| | | feedbackId.value = undefined; |
| | | feedbackStatus.value = undefined; |
| | | originalSnapshot.value = ''; |
| | | paramSnapshot.value = undefined; |
| | | paramRenderKey.value++; |
| | | |
| | | formApi.setState({ schema: useFormSchema(formType.value, formApi) }); |
| | | |
| | |
| | | checkFlag, |
| | | }); |
| | | |
| | | originalSnapshot.value = JSON.stringify(await getAlignedData()); |
| | | originalSnapshot.value = JSON.stringify(await getAlignedData(false)); |
| | | } |
| | | |
| | | /** 保存 */ |
| | |
| | | async function loadFeedback(id: number) { |
| | | const data = await getFeedback(id); |
| | | feedbackId.value = data.id; |
| | | paramSnapshot.value = data.paramSnapshot; |
| | | feedbackStatus.value = data.status; |
| | | formType.value = 'update'; |
| | | formApi.setState({ schema: useFormSchema(formType.value, formApi) }); |
| | | const checkFlag = await resolveCheckFlag(data.routeId, data.processId); |
| | | await formApi.setValues({ ...data, checkFlag }); |
| | | originalSnapshot.value = JSON.stringify(await getAlignedData()); |
| | | originalSnapshot.value = JSON.stringify(await getAlignedData(false)); |
| | | } |
| | | |
| | | // 监听任务变更(仅当任务 ID 真正变化时才重置表单) |
| | |
| | | </div> |
| | | |
| | | <Form class="feedback-tab__form" /> |
| | | <FeedbackParamFields :key="paramRenderKey" ref="paramFields" :task-id="task.id" :snapshot="paramSnapshot" :readonly="!isEditable" /> |
| | | |
| | | <div class="feedback-tab__actions"> |
| | | <Button |