| | |
| | | <up-input v-model="form.process" |
| | | placeholder="请选择工序" |
| | | readonly |
| | | :disabled="processQuantityDisabled" /> |
| | | :disabled="processQuantityDisabled || isReadonly" /> |
| | | <template #right> |
| | | <up-icon @click="showprocessSheet = true" |
| | | <up-icon @click="!isReadonly && (showprocessSheet = true)" |
| | | name="arrow-right" /> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | <up-input v-model="form.productName" |
| | | placeholder="请选择产品" |
| | | readonly |
| | | @click="showProductTree = true" |
| | | :disabled="isEdit" /> |
| | | @click="!isReadonly && (showProductTree = true)" |
| | | :disabled="isEdit || isReadonly" /> |
| | | <template #right> |
| | | <up-icon @click="showProductTree = true" |
| | | <up-icon @click="!isReadonly && (showProductTree = true)" |
| | | name="arrow-right" /> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | <up-input v-model="form.model" |
| | | placeholder="请选择规格型号" |
| | | readonly |
| | | :disabled="isEdit" /> |
| | | :disabled="isEdit || isReadonly" /> |
| | | <template #right> |
| | | <up-icon @click="showModelSheet = true" |
| | | <up-icon @click="!isReadonly && (showModelSheet = true)" |
| | | name="arrow-right" /> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | border-bottom> |
| | | <up-input v-model="testStandardDisplay" |
| | | placeholder="请选择指标" |
| | | readonly /> |
| | | readonly |
| | | :disabled="isReadonly" /> |
| | | <template #right> |
| | | <up-icon @click="openTestStandardSheet" |
| | | name="arrow-right" /> |
| | |
| | | <up-input v-model="form.quantity" |
| | | type="number" |
| | | placeholder="请输入数量" |
| | | :disabled="processQuantityDisabled" /> |
| | | :disabled="processQuantityDisabled || isReadonly" /> |
| | | </up-form-item> |
| | | <up-form-item label="检测单位" |
| | | prop="checkCompany" |
| | | border-bottom> |
| | | <up-input v-model="form.checkCompany" |
| | | placeholder="请输入检测单位" |
| | | :disabled="isReadonly" |
| | | clearable /> |
| | | </up-form-item> |
| | | <up-form-item label="检测结果" |
| | |
| | | <up-input v-model="form.checkResult" |
| | | placeholder="请选择检测结果" |
| | | readonly |
| | | :disabled="isReadonly" |
| | | @click="showResultSheet" /> |
| | | <template #right> |
| | | <up-icon @click="showResultSheet = true" |
| | | <up-icon @click="!isReadonly && (showResultSheet = true)" |
| | | name="arrow-right" /> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | <up-input v-model="form.checkName" |
| | | placeholder="请选择检验员" |
| | | readonly |
| | | :disabled="isReadonly" |
| | | @click="showInspectorSheet" /> |
| | | <template #right> |
| | | <up-icon @click="showInspectorSheet = true" |
| | | <up-icon @click="!isReadonly && (showInspectorSheet = true)" |
| | | name="arrow-right" /> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | border-bottom> |
| | | <up-input v-model="form.checkTime" |
| | | placeholder="请选择检测日期" |
| | | readonly /> |
| | | readonly |
| | | :disabled="isReadonly" /> |
| | | <!-- <template #right> |
| | | <up-icon name="calendar" |
| | | @click="showDatePicker"></up-icon> |
| | |
| | | <text class="step-label">检验值:</text> |
| | | <up-input v-model="item.testValue" |
| | | placeholder="请输入检验值" |
| | | :disabled="isReadonly" |
| | | clearable |
| | | border-bottom |
| | | class="step-input" /> |
| | |
| | | size="default" |
| | | @click="goBack" |
| | | class="bottom-btn"> |
| | | 取消 |
| | | {{ isReadonly ? '返回' : '取消' }} |
| | | </up-button> |
| | | <up-button type="primary" |
| | | <!-- 已提交单据只读,隐藏保存/提交 --> |
| | | <up-button v-if="!isReadonly" |
| | | type="primary" |
| | | size="default" |
| | | @click="submitForm" |
| | | :loading="loading" |
| | | class="bottom-btn"> |
| | | {{ isEdit ? '保存' : '提交' }} |
| | | 保存 |
| | | </up-button> |
| | | </view> |
| | | <!-- 日期选择器 --> |
| | |
| | | return !!(v.productMainId != null || v.purchaseLedgerId != null); |
| | | }); |
| | | |
| | | // 已提交(inspectState=1)单据整体只读 |
| | | const isReadonly = computed(() => Number(form.value?.inspectState) === 1); |
| | | |
| | | // 返回上一页 |
| | | const goBack = () => { |
| | | uni.navigateBack(); |
| | |
| | | |
| | | // 显示日期选择器 |
| | | const showDatePicker = () => { |
| | | if (isReadonly.value) return; |
| | | showDate.value = true; |
| | | }; |
| | | |
| | | // 确认日期选择 |
| | | const confirmDate = e => { |
| | | if (isReadonly.value) return; |
| | | form.value.checkTime = dayjs(e.value).format("YYYY-MM-DD"); |
| | | }; |
| | | |
| | |
| | | }); |
| | | }; |
| | | const openTestStandardSheet = () => { |
| | | console.log("openTestStandardSheet"); |
| | | if (isReadonly.value) return; |
| | | showTestStandardSheet.value = true; |
| | | }; |
| | | |
| | |
| | | // 提交表单 |
| | | const submitForm = async () => { |
| | | console.log("submitForm", form.value, tableData.value); |
| | | // 已提交单据禁止保存/提交 |
| | | if (isReadonly.value) { |
| | | showToast("检验单已提交,不允许修改"); |
| | | return; |
| | | } |
| | | try { |
| | | // await formRef.value.validate(); |
| | | if (!form.value.productModelId) { |
| | |
| | | const data = { ...form.value, qualityInspectParams: tableData.value }; |
| | | data.quantity = Number(data.quantity); |
| | | if (isEdit.value) { |
| | | const res = await qualityInspectUpdate(data); |
| | | await qualityInspectUpdate(data); |
| | | showToast("保存成功"); |
| | | setTimeout(() => { |
| | | uni.navigateBack(); |
| | | }, 1500); |
| | | } else { |
| | | const res = await qualityInspectAdd(data); |
| | | showToast("提交成功"); |
| | | // 新增仅保存草稿,正式提交在列表页「提交」按钮 |
| | | await qualityInspectAdd(data); |
| | | showToast("保存成功"); |
| | | setTimeout(() => { |
| | | uni.navigateBack(); |
| | | }, 1500); |
| | | } |
| | | } catch (error) { |
| | | console.error("表单验证失败:", error); |
| | | showToast("提交失败,请重试"); |
| | | // request.ts 已统一 toast 后端 msg,这里只记录 |
| | | console.error("提交失败:", error); |
| | | } finally { |
| | | loading.value = false; |
| | | } |