diff --git a/apps/web-antd/src/views/mes/md/autocode/data.ts b/apps/web-antd/src/views/mes/md/autocode/data.ts
index 4613d02fd..30163e038 100644
--- a/apps/web-antd/src/views/mes/md/autocode/data.ts
+++ b/apps/web-antd/src/views/mes/md/autocode/data.ts
@@ -448,10 +448,7 @@ export function usePartGridColumns(): VxeTableGridOptions
+
+
+
+import { computed, ref, watch } from 'vue';
+
+import { MesQcResultValueType } from '@vben/constants';
+
+import { RadioGroup, Select } from 'ant-design-vue';
+
+import { getSimpleDictTypeList } from '#/api/system/dict/type';
+
+defineOptions({ name: 'QcIndicatorResultSpecificationInput' });
+
+const props = withDefaults(
+ defineProps<{
+ modelValue?: string;
+ resultType?: number;
+ }>(),
+ {
+ modelValue: undefined,
+ resultType: undefined,
+ },
+);
+const emit = defineEmits<{
+ 'update:modelValue': [value?: string];
+}>();
+
+const fileOptions = [
+ { label: '图片/照片', value: 'IMG' },
+ { label: '文件', value: 'FILE' },
+];
+const dictTypeOptions = ref<{ name?: string; type?: string }[]>([]);
+
+const innerValue = computed({
+ get: () => props.modelValue,
+ set: (value?: string) => emit('update:modelValue', value),
+});
+
+/** 加载字典类型选项(仅字典类型结果值需要) */
+async function loadDictTypeOptions() {
+ if (dictTypeOptions.value.length > 0) {
+ return;
+ }
+ dictTypeOptions.value = await getSimpleDictTypeList();
+}
+
+watch(
+ () => props.resultType,
+ (value) => {
+ if (value === MesQcResultValueType.DICT) {
+ void loadDictTypeOptions();
+ }
+ },
+ { immediate: true },
+);
+
+
+
+
+
+
diff --git a/apps/web-antd/src/views/mes/qc/indicator/data.ts b/apps/web-antd/src/views/mes/qc/indicator/data.ts
index 0f8e3d14d..4dff05f3d 100644
--- a/apps/web-antd/src/views/mes/qc/indicator/data.ts
+++ b/apps/web-antd/src/views/mes/qc/indicator/data.ts
@@ -2,7 +2,7 @@ import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesQcIndicatorApi } from '#/api/mes/qc/indicator';
-import { h } from 'vue';
+import { h, markRaw } from 'vue';
import { DICT_TYPE, MesAutoCodeRuleCode, MesQcResultValueType } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@@ -10,7 +10,8 @@ import { getDictOptions } from '@vben/hooks';
import { Button } from 'ant-design-vue';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
-import { getSimpleDictTypeList } from '#/api/system/dict/type';
+
+import { QcIndicatorResultSpecificationInput } from './components';
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
@@ -93,37 +94,17 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
},
{
fieldName: 'resultSpecification',
- label: '文件类型',
- component: 'RadioGroup',
- componentProps: {
- options: [
- { label: '图片/照片', value: 'IMG' },
- { label: '文件', value: 'FILE' },
- ],
- },
+ label: '结果值属性',
+ component: markRaw(QcIndicatorResultSpecificationInput),
+ // 按结果值类型在组件内部切换文件类型 RadioGroup / 字典类型 ApiSelect
dependencies: {
triggerFields: ['resultType'],
- show: (values) => values.resultType === MesQcResultValueType.FILE,
- },
- rules: 'required',
- },
- {
- fieldName: 'resultSpecification',
- label: '字典类型',
- component: 'ApiSelect',
- componentProps: {
- allowClear: true,
- api: getSimpleDictTypeList,
- filterOption: (input: string, option: any) =>
- (option.label as string).toLowerCase().includes(input.toLowerCase()),
- labelField: 'name',
- placeholder: '请选择字典类型',
- showSearch: true,
- valueField: 'type',
- },
- dependencies: {
- triggerFields: ['resultType'],
- show: (values) => values.resultType === MesQcResultValueType.DICT,
+ if: (values) =>
+ values.resultType === MesQcResultValueType.FILE ||
+ values.resultType === MesQcResultValueType.DICT,
+ componentProps: (values) => ({
+ resultType: values.resultType,
+ }),
},
rules: 'required',
},
diff --git a/apps/web-antd/src/views/mes/qc/oqc/modules/form.vue b/apps/web-antd/src/views/mes/qc/oqc/modules/form.vue
index 11f1d4b50..19b91b4b7 100644
--- a/apps/web-antd/src/views/mes/qc/oqc/modules/form.vue
+++ b/apps/web-antd/src/views/mes/qc/oqc/modules/form.vue
@@ -171,10 +171,15 @@ const [Modal, modalApi] = useVbenModal({
modalApi.unlock();
}
} else if (data?.prefill) {
- // 预填模式:来自待检任务
- formData.value = { ...data.prefill };
+ // 预填模式:来自待检任务。源项目靠 watcher 自动把 outQuantity 同步到
+ // checkQuantity,这里显式补齐,避免必填的检测数量为空
+ const prefill = {
+ ...data.prefill,
+ checkQuantity: data.prefill.checkQuantity ?? data.prefill.outQuantity,
+ };
+ formData.value = { ...prefill };
// 设置到 values
- await formApi.setValues(data.prefill);
+ await formApi.setValues(prefill);
}
originalSnapshot.value = JSON.stringify(await formApi.getValues());
},
diff --git a/apps/web-antd/src/views/mes/wm/stocktaking/task/data.ts b/apps/web-antd/src/views/mes/wm/stocktaking/task/data.ts
index ef929cf01..441978de7 100644
--- a/apps/web-antd/src/views/mes/wm/stocktaking/task/data.ts
+++ b/apps/web-antd/src/views/mes/wm/stocktaking/task/data.ts
@@ -501,6 +501,11 @@ export function useResultFormSchema(
placeholder: '请选择物料',
},
rules: 'selectRequired',
+ // 选中盘点清单后,物料由清单带出且禁止改动
+ dependencies: {
+ triggerFields: ['lineId'],
+ disabled: (values) => values.lineId != null,
+ },
},
{
fieldName: 'batchCode',
@@ -509,6 +514,11 @@ export function useResultFormSchema(
componentProps: {
placeholder: '请输入批次编码',
},
+ // 选中盘点清单后,批次由清单带出且禁止改动
+ dependencies: {
+ triggerFields: ['lineId'],
+ disabled: (values) => values.lineId != null,
+ },
},
{
fieldName: 'takingQuantity',
@@ -535,6 +545,11 @@ export function useResultFormSchema(
placeholder: '请选择仓库',
},
rules: 'selectRequired',
+ // 选中盘点清单后,仓库由清单带出且禁止改动
+ dependencies: {
+ triggerFields: ['lineId'],
+ disabled: (values) => values.lineId != null,
+ },
},
{
fieldName: 'locationId',
@@ -542,8 +557,10 @@ export function useResultFormSchema(
component: markRaw(WmWarehouseLocationSelect),
rules: 'selectRequired',
dependencies: {
- triggerFields: ['warehouseId'],
+ triggerFields: ['warehouseId', 'lineId'],
show: (values) => !!values.warehouseId,
+ // 选中盘点清单后,库区由清单带出且禁止改动
+ disabled: (values) => values.lineId != null,
componentProps: (values) => ({
onChange: () => formApi?.setFieldValue('areaId', undefined),
placeholder: '请选择库区',
@@ -557,8 +574,10 @@ export function useResultFormSchema(
component: markRaw(WmWarehouseAreaSelect),
rules: 'selectRequired',
dependencies: {
- triggerFields: ['locationId'],
+ triggerFields: ['locationId', 'lineId'],
show: (values) => !!values.locationId,
+ // 选中盘点清单后,库位由清单带出且禁止改动
+ disabled: (values) => values.lineId != null,
componentProps: (values) => ({
locationId: values.locationId,
placeholder: '请选择库位',
diff --git a/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/form.vue b/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/form.vue
index 05cc93b33..ec1c5ba76 100644
--- a/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/form.vue
+++ b/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/form.vue
@@ -49,25 +49,19 @@ const showResultTab = computed(
(!!formData.value?.status &&
formData.value.status !== MesWmStockTakingTaskStatusEnum.PREPARE),
);
-// TODO @AI:这里的代码风格,标题的代码风格;
const getTitle = computed(() => {
- switch (formType.value) {
- case 'detail': {
- return $t('ui.actionTitle.view', ['盘点任务']);
- }
- case 'execute': {
- return '执行盘点';
- }
- case 'submit': {
- return '提交盘点任务';
- }
- case 'update': {
- return $t('ui.actionTitle.edit', ['盘点任务']);
- }
- default: {
- return $t('ui.actionTitle.create', ['盘点任务']);
- }
+ if (formType.value === 'detail') {
+ return $t('ui.actionTitle.view', ['盘点任务']);
}
+ if (formType.value === 'execute') {
+ return '执行盘点';
+ }
+ if (formType.value === 'submit') {
+ return '提交盘点任务';
+ }
+ return formType.value === 'update'
+ ? $t('ui.actionTitle.edit', ['盘点任务'])
+ : $t('ui.actionTitle.create', ['盘点任务']);
});
const [Form, formApi] = useVbenForm({
@@ -125,7 +119,6 @@ async function handleExecute() {
}
const [Modal, modalApi] = useVbenModal({
- // TODO @AI:注释风格,代码的;
async onConfirm() {
if (!isEditable.value) {
await modalApi.close();
diff --git a/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/result-form.vue b/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/result-form.vue
index 57163739b..9d21b6750 100644
--- a/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/result-form.vue
+++ b/apps/web-antd/src/views/mes/wm/stocktaking/task/modules/result-form.vue
@@ -20,7 +20,7 @@ import { useResultFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref();
-const taskId = ref(); // TODO @AI:尾注释;
+const taskId = ref(); // 所属盘点任务编号
const isExecute = ref(false); // 是否执行盘点模式(可选择盘点清单回填)
const getTitle = computed(() =>
formData.value?.id
diff --git a/apps/web-ele/src/views/mes/md/autocode/data.ts b/apps/web-ele/src/views/mes/md/autocode/data.ts
index 38aa69aee..576b4a2a9 100644
--- a/apps/web-ele/src/views/mes/md/autocode/data.ts
+++ b/apps/web-ele/src/views/mes/md/autocode/data.ts
@@ -448,10 +448,7 @@ export function usePartGridColumns(): VxeTableGridOptions
+
+
+
+import { computed, ref, watch } from 'vue';
+
+import { MesQcResultValueType } from '@vben/constants';
+
+import { ElOption, ElRadioButton, ElRadioGroup, ElSelect } from 'element-plus';
+
+import { getSimpleDictTypeList } from '#/api/system/dict/type';
+
+defineOptions({ name: 'QcIndicatorResultSpecificationInput' });
+
+const props = withDefaults(
+ defineProps<{
+ modelValue?: string;
+ resultType?: number;
+ }>(),
+ {
+ modelValue: undefined,
+ resultType: undefined,
+ },
+);
+const emit = defineEmits<{
+ 'update:modelValue': [value?: string];
+}>();
+
+const fileOptions = [
+ { label: '图片/照片', value: 'IMG' },
+ { label: '文件', value: 'FILE' },
+];
+const dictTypeOptions = ref<{ name?: string; type?: string }[]>([]);
+
+const innerValue = computed({
+ get: () => props.modelValue,
+ set: (value?: string) => emit('update:modelValue', value),
+});
+
+/** 加载字典类型选项(仅字典类型结果值需要) */
+async function loadDictTypeOptions() {
+ if (dictTypeOptions.value.length > 0) {
+ return;
+ }
+ dictTypeOptions.value = await getSimpleDictTypeList();
+}
+
+watch(
+ () => props.resultType,
+ (value) => {
+ if (value === MesQcResultValueType.DICT) {
+ void loadDictTypeOptions();
+ }
+ },
+ { immediate: true },
+);
+
+
+
+
+
+ {{ option.label }}
+
+
+
+
+
+
diff --git a/apps/web-ele/src/views/mes/qc/indicator/data.ts b/apps/web-ele/src/views/mes/qc/indicator/data.ts
index caf816c66..18a61504d 100644
--- a/apps/web-ele/src/views/mes/qc/indicator/data.ts
+++ b/apps/web-ele/src/views/mes/qc/indicator/data.ts
@@ -2,7 +2,7 @@ import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesQcIndicatorApi } from '#/api/mes/qc/indicator';
-import { h } from 'vue';
+import { h, markRaw } from 'vue';
import { DICT_TYPE, MesAutoCodeRuleCode, MesQcResultValueType } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@@ -10,7 +10,8 @@ import { getDictOptions } from '@vben/hooks';
import { ElButton } from 'element-plus';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
-import { getSimpleDictTypeList } from '#/api/system/dict/type';
+
+import { QcIndicatorResultSpecificationInput } from './components';
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
@@ -92,37 +93,17 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
},
{
fieldName: 'resultSpecification',
- label: '文件类型',
- component: 'RadioGroup',
- componentProps: {
- options: [
- { label: '图片/照片', value: 'IMG' },
- { label: '文件', value: 'FILE' },
- ],
- },
+ label: '结果值属性',
+ component: markRaw(QcIndicatorResultSpecificationInput),
+ // 按结果值类型在组件内部切换文件类型 RadioGroup / 字典类型 Select
dependencies: {
triggerFields: ['resultType'],
- show: (values) => values.resultType === MesQcResultValueType.FILE,
- },
- rules: 'required',
- },
- {
- fieldName: 'resultSpecification',
- label: '字典类型',
- component: 'ApiSelect',
- componentProps: {
- api: getSimpleDictTypeList,
- clearable: true,
- filterMethod: (input: string, option: any) =>
- (option.label as string).toLowerCase().includes(input.toLowerCase()),
- filterable: true,
- labelField: 'name',
- placeholder: '请选择字典类型',
- valueField: 'type',
- },
- dependencies: {
- triggerFields: ['resultType'],
- show: (values) => values.resultType === MesQcResultValueType.DICT,
+ if: (values) =>
+ values.resultType === MesQcResultValueType.FILE ||
+ values.resultType === MesQcResultValueType.DICT,
+ componentProps: (values) => ({
+ resultType: values.resultType,
+ }),
},
rules: 'required',
},
diff --git a/apps/web-ele/src/views/mes/qc/oqc/modules/form.vue b/apps/web-ele/src/views/mes/qc/oqc/modules/form.vue
index e2bb0b551..dce60cfec 100644
--- a/apps/web-ele/src/views/mes/qc/oqc/modules/form.vue
+++ b/apps/web-ele/src/views/mes/qc/oqc/modules/form.vue
@@ -178,10 +178,15 @@ const [Modal, modalApi] = useVbenModal({
modalApi.unlock();
}
} else if (data?.prefill) {
- // 预填模式:来自待检任务
- formData.value = { ...data.prefill };
+ // 预填模式:来自待检任务。源项目靠 watcher 自动把 outQuantity 同步到
+ // checkQuantity,这里显式补齐,避免必填的检测数量为空
+ const prefill = {
+ ...data.prefill,
+ checkQuantity: data.prefill.checkQuantity ?? data.prefill.outQuantity,
+ };
+ formData.value = { ...prefill };
// 设置到 values
- await formApi.setValues(data.prefill);
+ await formApi.setValues(prefill);
}
originalSnapshot.value = JSON.stringify(await formApi.getValues());
},
diff --git a/apps/web-ele/src/views/mes/wm/stocktaking/task/data.ts b/apps/web-ele/src/views/mes/wm/stocktaking/task/data.ts
index 1d617f4dd..bcc051afc 100644
--- a/apps/web-ele/src/views/mes/wm/stocktaking/task/data.ts
+++ b/apps/web-ele/src/views/mes/wm/stocktaking/task/data.ts
@@ -502,6 +502,11 @@ export function useResultFormSchema(
placeholder: '请选择物料',
},
rules: 'selectRequired',
+ // 选中盘点清单后,物料由清单带出且禁止改动
+ dependencies: {
+ triggerFields: ['lineId'],
+ disabled: (values) => values.lineId != null,
+ },
},
{
fieldName: 'batchCode',
@@ -510,6 +515,11 @@ export function useResultFormSchema(
componentProps: {
placeholder: '请输入批次编码',
},
+ // 选中盘点清单后,批次由清单带出且禁止改动
+ dependencies: {
+ triggerFields: ['lineId'],
+ disabled: (values) => values.lineId != null,
+ },
},
{
fieldName: 'takingQuantity',
@@ -537,6 +547,11 @@ export function useResultFormSchema(
placeholder: '请选择仓库',
},
rules: 'selectRequired',
+ // 选中盘点清单后,仓库由清单带出且禁止改动
+ dependencies: {
+ triggerFields: ['lineId'],
+ disabled: (values) => values.lineId != null,
+ },
},
{
fieldName: 'locationId',
@@ -544,8 +559,10 @@ export function useResultFormSchema(
component: markRaw(WmWarehouseLocationSelect),
rules: 'selectRequired',
dependencies: {
- triggerFields: ['warehouseId'],
+ triggerFields: ['warehouseId', 'lineId'],
show: (values) => !!values.warehouseId,
+ // 选中盘点清单后,库区由清单带出且禁止改动
+ disabled: (values) => values.lineId != null,
componentProps: (values) => ({
onChange: () => formApi?.setFieldValue('areaId', undefined),
placeholder: '请选择库区',
@@ -559,8 +576,10 @@ export function useResultFormSchema(
component: markRaw(WmWarehouseAreaSelect),
rules: 'selectRequired',
dependencies: {
- triggerFields: ['locationId'],
+ triggerFields: ['locationId', 'lineId'],
show: (values) => !!values.locationId,
+ // 选中盘点清单后,库位由清单带出且禁止改动
+ disabled: (values) => values.lineId != null,
componentProps: (values) => ({
locationId: values.locationId,
placeholder: '请选择库位',
diff --git a/apps/web-ele/src/views/mes/wm/stocktaking/task/modules/form.vue b/apps/web-ele/src/views/mes/wm/stocktaking/task/modules/form.vue
index e2dfb6e60..b1446a914 100644
--- a/apps/web-ele/src/views/mes/wm/stocktaking/task/modules/form.vue
+++ b/apps/web-ele/src/views/mes/wm/stocktaking/task/modules/form.vue
@@ -50,23 +50,18 @@ const showResultTab = computed(
formData.value.status !== MesWmStockTakingTaskStatusEnum.PREPARE),
);
const getTitle = computed(() => {
- switch (formType.value) {
- case 'detail': {
- return $t('ui.actionTitle.view', ['盘点任务']);
- }
- case 'execute': {
- return '执行盘点';
- }
- case 'submit': {
- return '提交盘点任务';
- }
- case 'update': {
- return $t('ui.actionTitle.edit', ['盘点任务']);
- }
- default: {
- return $t('ui.actionTitle.create', ['盘点任务']);
- }
+ if (formType.value === 'detail') {
+ return $t('ui.actionTitle.view', ['盘点任务']);
}
+ if (formType.value === 'execute') {
+ return '执行盘点';
+ }
+ if (formType.value === 'submit') {
+ return '提交盘点任务';
+ }
+ return formType.value === 'update'
+ ? $t('ui.actionTitle.edit', ['盘点任务'])
+ : $t('ui.actionTitle.create', ['盘点任务']);
});
const [Form, formApi] = useVbenForm({