From 173855b299e89930b5ea2ff9a9295fde9d0f55b5 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 07 十一月 2026 08:51:43 +0800
Subject: [PATCH] feat: 同步质检、生产、销售、财务与人事前端功能
---
src/views/mes/qc/ipqc/modules/form.vue | 713 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 709 insertions(+), 4 deletions(-)
diff --git a/src/views/mes/qc/ipqc/modules/form.vue b/src/views/mes/qc/ipqc/modules/form.vue
index 5752a47..0ee423b 100644
--- a/src/views/mes/qc/ipqc/modules/form.vue
+++ b/src/views/mes/qc/ipqc/modules/form.vue
@@ -1,17 +1,53 @@
<script lang="ts" setup>
import type { FormType } from '../data';
+import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
+import type { MesQcIndicatorResultApi } from '#/api/mes/qc/indicatorresult';
import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc';
import { computed, ref } from 'vue';
import { confirm, useVbenModal } from '@vben/common-ui';
-import { MesQcStatusEnum } from '@vben/constants';
+import {
+ MesQcResultValueType,
+ MesQcStatusEnum,
+ MesQcTypeEnum,
+} from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
-import { Button, message, Tabs } from 'ant-design-vue';
+import {
+ Alert,
+ Button,
+ Empty,
+ Input,
+ InputNumber,
+ message,
+ Popconfirm,
+ Select,
+ Table,
+ Tabs,
+ Upload,
+} from 'ant-design-vue';
+
+import { requestClient } from '#/api/request';
+import { uploadFile, type SystemStorageApi } from '#/api/system/storage';
import { useVbenForm } from '#/adapter/form';
-import { createIpqc, finishIpqc, getIpqc, updateIpqc } from '#/api/mes/qc/ipqc';
+import {
+ createIndicatorResult,
+ getIndicatorResultDetail,
+ getIndicatorResultPage,
+ updateIndicatorResult,
+} from '#/api/mes/qc/indicatorresult';
+import {
+ createIpqc,
+ finishIpqc,
+ getIpqc,
+ getIpqcWageFieldList,
+ getTemplateByProcess,
+ saveIpqcWageFieldValues,
+ updateIpqc,
+} from '#/api/mes/qc/ipqc';
import { $t } from '#/locales';
import QcAttachments from '../../components/qc-attachments.vue';
@@ -24,6 +60,12 @@
const subTabsName = ref('attachments');
const originalSnapshot = ref(''); // 琛ㄥ崟鍘熷鏁版嵁蹇収锛岀敤浜� finish 鏃惰烦杩囨湭鍙樻洿鐨勪繚瀛樿姹�
const isDetail = computed(() => formType.value === 'detail');
+/** 宸ヤ綅鎵�灞炲伐搴忕殑榛樿璐ㄦ鏂规鍙婃娴嬫寚鏍囷紙閫夊伐浣嶅悗鑷姩甯﹀嚭锛� */
+const resolvedScheme = ref<MesQcIpqcApi.TemplateResolve>();
+const resolvingScheme = ref(false);
+const showSchemeCard = computed(
+ () => resolvingScheme.value || resolvedScheme.value?.processId !== undefined,
+);
const canFinish = computed(
() =>
formType.value === 'update' &&
@@ -37,6 +79,447 @@
? $t('ui.actionTitle.edit', ['杩囩▼妫�楠屽崟'])
: $t('ui.actionTitle.create', ['杩囩▼妫�楠屽崟']);
});
+
+/** 娓呯┖宸茶В鏋愮殑鏂规锛堝叧闂垨閲嶅紑寮圭獥鏃堕伩鍏嶆畫鐣欙級 */
+function resetResolvedScheme() {
+ resolvedScheme.value = undefined;
+}
+
+/**
+ * 鎸夊伐搴忚В鏋愰粯璁よ川妫�鏂规锛屽苟鎶婃柟妗堝洖濉埌琛ㄥ崟
+ *
+ * @param processId 宸ュ簭缂栧彿
+ * @param force true=浠ヨВ鏋愮粨鏋滆鐩栧凡閫夋柟妗堬紙宸ヤ綅鍙樻洿鏃讹級锛沠alse=浠呭湪鏈�夋柟妗堟椂鍥炲~锛堟墦寮�宸叉湁鍗曟嵁鏃讹級
+ */
+async function resolveScheme(processId?: number, force = false) {
+ if (!processId) {
+ resolvedScheme.value = undefined;
+ if (force) {
+ await formApi.setFieldValue('templateId', undefined);
+ }
+ return;
+ }
+ resolvingScheme.value = true;
+ try {
+ const resp = await getTemplateByProcess(processId, MesQcTypeEnum.IPQC);
+ resolvedScheme.value = resp;
+ const current = await formApi.getValues();
+ if (force ? true : !current.templateId) {
+ await formApi.setFieldValue('templateId', resp?.templateId);
+ }
+ } catch {
+ resolvedScheme.value = undefined;
+ } finally {
+ resolvingScheme.value = false;
+ }
+}
+
+/** 宸ヤ綅鍙樻洿锛氬甫鍑哄伐浣嶆墍灞炲伐搴忥紝骞惰В鏋愰粯璁よ川妫�鏂规涓庢娴嬫寚鏍� */
+async function handleWorkstationChange(
+ item?: MesMdWorkstationApi.Workstation,
+) {
+ if (!formData.value?.id) {
+ // 鏂板缓鍗曟嵁鎹㈠伐搴忥細涓婁竴娆$殑妫�娴嬪�间笉鍐嶉�傜敤
+ indicatorResultId.value = undefined;
+ }
+ if (item?.processId) {
+ await formApi.setFieldValue('processId', item.processId);
+ }
+ await handleProcessChange(item?.processId);
+}
+
+/** 妫�楠屽伐搴忓彉鏇达細閲嶆柊瑙f瀽榛樿璐ㄦ鏂规涓庢楠岄」 */
+async function handleProcessChange(processId?: number) {
+ if (!formData.value?.id) {
+ indicatorResultId.value = undefined;
+ }
+ await resolveScheme(processId, true);
+ buildRowsFromScheme();
+ // 宸ュ簭鍙樹簡锛氭寜鏂板伐搴忛噸鏂板甫鍑哄伐璧勫瓧娈�
+ await loadWageFields(processId, formData.value?.id);
+}
+
+/** 浠庡伐搴忔ā鏉夸腑杩藉姞涓�涓皻鏈娇鐢ㄧ殑妫�楠岄」 */
+function handleAddIndicator() {
+ const used = new Set(indicatorRows.value.map((row) => row.indicatorId));
+ const next = (resolvedScheme.value?.indicators ?? []).find(
+ (indicator) => !used.has(indicator.indicatorId),
+ );
+ if (!next) {
+ message.warning('璇ュ伐搴忕殑妫�楠岄」宸插叏閮ㄦ坊鍔狅紝娌℃湁鍙柊澧炵殑妫�楠岄」');
+ return;
+ }
+ indicatorRows.value.push({
+ indicatorId: next.indicatorId,
+ indicatorName: next.indicatorName,
+ valueType: next.resultType,
+ valueSpecification: next.resultSpecification,
+ standardValue: next.standardValue,
+ unitText: next.unitText,
+ thresholdMin: next.thresholdMin,
+ thresholdMax: next.thresholdMax,
+ blobIds: [],
+ files: [],
+ attachmentTouched: false,
+ });
+}
+
+/** 鍒犻櫎涓�琛屾楠岄」锛堣嚦灏戜繚鐣欎竴琛岋級 */
+function handleRemoveIndicator(index: number) {
+ if (indicatorRows.value.length <= 1) {
+ message.warning('鑷冲皯淇濈暀涓�琛屾楠岄」');
+ return;
+ }
+ indicatorRows.value.splice(index, 1);
+}
+
+/** 璇诲彇鏌愭潯妫�楠岃宸蹭笂浼犵殑闄勪欢 */
+async function loadRowAttachments(row: IndicatorValueRow) {
+ if (!row.detailId) {
+ return;
+ }
+ const files = await requestClient.get<SystemStorageApi.StorageBlob[]>(
+ '/mes/qc/attachment/ipqc-detail/list',
+ { params: { detailId: row.detailId } },
+ );
+ row.files = files ?? [];
+ row.blobIds = row.files.map((file) => file.id);
+ row.attachmentTouched = false;
+}
+
+/** 涓婁紶鏌愯妫�楠岄檮浠讹紙浠呬紶闄勪欢锛屼笉濉娴嬪�硷級 */
+async function handleRowUpload(row: IndicatorValueRow, file: File) {
+ const uploaded = await uploadFile([file]);
+ const blob = uploaded?.[0];
+ if (!blob?.id) {
+ throw new Error('涓婁紶缁撴灉缂哄皯鏂囦欢缂栧彿');
+ }
+ row.files = [...(row.files ?? []), blob];
+ row.blobIds = [...(row.blobIds ?? []), blob.id];
+ row.attachmentTouched = true;
+ message.success('闄勪欢宸蹭笂浼狅紝淇濆瓨妫�楠屽崟鍚庣敓鏁�');
+ return Upload.LIST_IGNORE;
+}
+
+/** 绉婚櫎鏌愯闄勪欢锛氬凡淇濆瓨鐨勭珛鍗宠В缁戯紝鏈繚瀛樼殑鍙粠鏈湴绉婚櫎 */
+async function handleRowRemoveFile(row: IndicatorValueRow, blobId: number) {
+ if (row.detailId) {
+ await requestClient.delete('/mes/qc/attachment/ipqc-detail/remove', {
+ params: { detailId: row.detailId, blobId },
+ });
+ }
+ row.files = (row.files ?? []).filter((file) => file.id !== blobId);
+ row.blobIds = (row.blobIds ?? []).filter((id) => id !== blobId);
+ row.attachmentTouched = true;
+ message.success('闄勪欢宸茬Щ闄�');
+}
+
+/** 淇濆瓨鍚勮闄勪欢缁戝畾锛堥渶鍦ㄦ楠岀粨鏋滄槑缁嗙敓鎴愬悗璋冪敤锛� */
+async function saveRowAttachments() {
+ for (const row of indicatorRows.value) {
+ if (!row.detailId || !row.attachmentTouched) {
+ continue;
+ }
+ await requestClient.post('/mes/qc/attachment/ipqc-detail/save', {
+ detailId: row.detailId,
+ blobIds: row.blobIds ?? [],
+ });
+ row.attachmentTouched = false;
+ }
+}
+
+/** 宸ヨ祫瀛楁锛堝伐搴忚嚜瀹氫箟瀛楁锛岀敱璐ㄦ濉啓鍚庡弬涓庡伐璧勮绠楋級 */
+interface WageFieldRow {
+ fieldId?: number;
+ fieldCode?: string;
+ fieldName?: string;
+ fieldType?: number;
+ unit?: string;
+ calcRole?: number;
+ unitPrice?: number;
+ defaultValue?: string;
+ value?: string;
+ valueNumber?: number;
+ remark?: string;
+}
+
+/** 宸ヨ祫瀛楁绫诲瀷锛�1-鏁板�� 2-鏂囨湰 3-涓嬫媺 4-甯冨皵 */
+const WAGE_FIELD_TYPE_NUMBER = 1;
+const WAGE_FIELD_TYPE_BOOLEAN = 4;
+/** 宸ヨ祫瀛楁璁$畻瑙掕壊鏂囨 */
+const WAGE_CALC_ROLE_LABEL: Record<number, string> = {
+ 1: '绯绘暟',
+ 2: '鍔犲噺閲戦',
+ 3: '璁′环鏁伴噺',
+ 4: '浠呰褰�',
+};
+
+const wageFields = ref<WageFieldRow[]>([]);
+
+/** 鎸夊伐搴忓甫鍑哄伐璧勫瓧娈碉紝骞跺洖濉妫�楠屽崟宸插~鍐欑殑鍊� */
+async function loadWageFields(processId?: number, ipqcId?: number) {
+ if (!processId && !ipqcId) {
+ wageFields.value = [];
+ return;
+ }
+ const list = await getIpqcWageFieldList({ processId, ipqcId });
+ wageFields.value = (list ?? []).map((field) => ({
+ ...field,
+ valueNumber:
+ field.fieldType === WAGE_FIELD_TYPE_NUMBER &&
+ field.value !== undefined &&
+ field.value !== null &&
+ String(field.value).trim() !== '' &&
+ Number.isFinite(Number(field.value))
+ ? Number(field.value)
+ : undefined,
+ }));
+}
+
+/** 淇濆瓨璐ㄦ濉啓鐨勫伐璧勫瓧娈靛�� */
+async function saveWageFieldValues(ipqcId: number) {
+ if (wageFields.value.length === 0) {
+ return;
+ }
+ await saveIpqcWageFieldValues(
+ ipqcId,
+ wageFields.value
+ .filter((field) => field.fieldId)
+ .map((field) => ({
+ fieldId: field.fieldId!,
+ value:
+ field.fieldType === WAGE_FIELD_TYPE_NUMBER
+ ? field.valueNumber === undefined || field.valueNumber === null
+ ? ''
+ : String(field.valueNumber)
+ : field.value || '',
+ remark: field.remark,
+ })),
+ );
+}
+
+/** 璇︽儏椤靛伐璧勫瓧娈靛�煎睍绀� */
+function getWageFieldDisplay(row: WageFieldRow) {
+ if (row.fieldType === WAGE_FIELD_TYPE_BOOLEAN && row.value) {
+ return row.value === '1' ? '鏄�' : '鍚�';
+ }
+ return row.value || '鏈~鍐�';
+}
+
+/** 妫�楠岄」濉啓琛岋紙鐢卞伐搴忛粯璁ゆ柟妗堢殑妫�娴嬫寚鏍囩敓鎴愶級 */
+interface IndicatorValueRow {
+ detailId?: number;
+ indicatorId?: number;
+ indicatorName?: string;
+ valueType?: number;
+ valueSpecification?: string;
+ standardValue?: number;
+ unitText?: string;
+ thresholdMin?: number;
+ thresholdMax?: number;
+ value?: string;
+ valueNumber?: number;
+ remark?: string;
+ /** 鏈鏂板銆佸皻鏈粦瀹氬埌妫�楠岃鏄庣粏鐨勯檮浠� blobId */
+ blobIds?: number[];
+ /** 妫�楠岃闄勪欢锛堝凡淇濆瓨鎴栨湰娆′笂浼犵殑灞曠ず鏁版嵁锛� */
+ files?: SystemStorageApi.StorageBlob[];
+ /** 闄勪欢鏄惁鏈夊彉鏇达紝淇濆瓨鏃堕渶閲嶆柊缁戝畾 */
+ attachmentTouched?: boolean;
+}
+
+/** 妫�楠岄」濉啓锛堟娴嬪�硷級锛岄殢妫�楠屽崟涓�璧蜂繚瀛樹负銆屾楠岀粨鏋溿�� */
+const indicatorRows = ref<IndicatorValueRow[]>([]);
+/** 宸蹭繚瀛樼殑妫�楠岀粨鏋滅紪鍙凤紱绌�=灏氭湭鐢熸垚 */
+const indicatorResultId = ref<number>();
+const indicatorResultCode = ref('榛樿');
+
+/** 鏁板�肩被妫�娴嬮」锛堟诞鐐�/鏁存暟锛夎蛋鏁板瓧杈撳叆 */
+function isNumericType(valueType?: number) {
+ return (
+ valueType === MesQcResultValueType.FLOAT ||
+ valueType === MesQcResultValueType.INTEGER
+ );
+}
+
+/** 瀛楀吀绫绘娴嬮」鐨勯�夐」锛坴alueSpecification 涓虹郴缁熷瓧鍏哥被鍨嬪悕锛� */
+function getDictValueOptions(dictType?: string) {
+ return dictType
+ ? getDictOptions(dictType, 'string').map(({ label, value }) => ({
+ label,
+ value: String(value),
+ }))
+ : [];
+}
+
+/** 鎸夊伐搴忛粯璁ゆ柟妗堢敓鎴愰渶瑕佸~鍐欑殑妫�楠岄」瀛楁锛屼繚鐣欏凡褰曞叆鐨勫�� */
+function buildRowsFromScheme() {
+ const previous = new Map(
+ indicatorRows.value.map((row) => [row.indicatorId, row]),
+ );
+ indicatorRows.value = (resolvedScheme.value?.indicators ?? []).map(
+ (indicator) => {
+ const old = previous.get(indicator.indicatorId);
+ return {
+ detailId: old?.detailId,
+ indicatorId: indicator.indicatorId,
+ indicatorName: indicator.indicatorName,
+ valueType: indicator.resultType,
+ valueSpecification: indicator.resultSpecification,
+ standardValue: indicator.standardValue,
+ unitText: indicator.unitText,
+ thresholdMin: indicator.thresholdMin,
+ thresholdMax: indicator.thresholdMax,
+ value: old?.value,
+ valueNumber: old?.valueNumber,
+ remark: old?.remark,
+ blobIds: old?.blobIds ?? [],
+ files: old?.files ?? [],
+ attachmentTouched: old?.attachmentTouched,
+ };
+ },
+ );
+}
+
+/** 鍔犺浇妫�楠屽崟宸蹭繚瀛樼殑妫�娴嬪�� */
+async function loadIndicatorValues(ipqcId: number) {
+ indicatorRows.value = [];
+ indicatorResultId.value = undefined;
+ indicatorResultCode.value = '榛樿';
+ const page = await getIndicatorResultPage({
+ pageNo: 1,
+ pageSize: 20,
+ qcId: ipqcId,
+ qcType: MesQcTypeEnum.IPQC,
+ });
+ const target =
+ (page.list ?? []).find(
+ (item) => !item.code || item.code === indicatorResultCode.value,
+ ) ?? page.list?.[0];
+ if (!target?.id) {
+ return;
+ }
+ const detail = await getIndicatorResultDetail(
+ ipqcId,
+ MesQcTypeEnum.IPQC,
+ target.id,
+ );
+ indicatorResultId.value = detail.id;
+ indicatorResultCode.value = detail.code || '榛樿';
+ indicatorRows.value = (detail.items ?? []).map((item) => ({
+ detailId: item.id,
+ indicatorId: item.indicatorId,
+ indicatorName: item.indicatorName,
+ valueType: item.valueType,
+ valueSpecification: item.valueSpecification,
+ value: item.value,
+ valueNumber:
+ isNumericType(item.valueType) &&
+ item.value !== undefined &&
+ item.value !== null &&
+ String(item.value).trim() !== '' &&
+ Number.isFinite(Number(item.value))
+ ? Number(item.value)
+ : undefined,
+ blobIds: [],
+ files: [],
+ attachmentTouched: false,
+ }));
+ // 閫愯鍔犺浇宸蹭笂浼犵殑妫�楠岄檮浠�
+ await Promise.all(indicatorRows.value.map((row) => loadRowAttachments(row)));
+}
+
+/** 鐢ㄥ伐搴忔柟妗堣ˉ榻愭楠岃鐨勫悕绉般�佹爣鍑嗗�间笌鍗曚綅锛堜笉鏀瑰彉宸蹭繚瀛樼殑琛岄『搴忓拰澧炲垹缁撴灉锛� */
+function enrichRowsFromScheme() {
+ const indicatorMap = new Map(
+ (resolvedScheme.value?.indicators ?? []).map((indicator) => [
+ indicator.indicatorId,
+ indicator,
+ ]),
+ );
+ indicatorRows.value.forEach((row) => {
+ const indicator = row.indicatorId
+ ? indicatorMap.get(row.indicatorId)
+ : undefined;
+ if (!indicator) {
+ return;
+ }
+ row.indicatorName ??= indicator.indicatorName;
+ row.valueType ??= indicator.resultType;
+ row.valueSpecification ??= indicator.resultSpecification;
+ row.standardValue ??= indicator.standardValue;
+ row.unitText ??= indicator.unitText;
+ row.thresholdMin ??= indicator.thresholdMin;
+ row.thresholdMax ??= indicator.thresholdMax;
+ });
+}
+
+/** 鏀堕泦褰撳墠妫�楠岃銆傝川妫�鍙紶闄勪欢锛屾娴嬪�肩粺涓�鐣欑┖锛岀敱闄勪欢鎵胯浇妫�娴嬬粨鏋溿�� */
+function collectIndicatorItems() {
+ return indicatorRows.value
+ .filter((row) => row.indicatorId)
+ .map((row) => ({
+ id: row.detailId,
+ indicatorId: row.indicatorId!,
+ value: '',
+ remark: row.remark,
+ }));
+}
+
+/** 淇濆瓨妫�楠岃锛堝惈鎵嬪伐澧炲垹鐨勮锛夛紝骞舵妸鐢熸垚鐨勬槑缁嗙紪鍙峰洖濉埌琛屼笂 */
+async function saveIndicatorValues(ipqcId: number) {
+ const items = collectIndicatorItems();
+ if (items.length === 0) {
+ return;
+ }
+ const payload: MesQcIndicatorResultApi.IndicatorResult = {
+ code: indicatorResultCode.value || '榛樿',
+ qcId: ipqcId,
+ qcType: MesQcTypeEnum.IPQC,
+ items,
+ };
+ if (indicatorResultId.value) {
+ payload.id = indicatorResultId.value;
+ await updateIndicatorResult(payload);
+ } else {
+ indicatorResultId.value = (await createIndicatorResult(
+ payload,
+ )) as number;
+ }
+ // 淇濆瓨鍚庢寜鎸囨爣鍥炲~鏄庣粏缂栧彿锛屼緵姣忚闄勪欢缁戝畾浣跨敤
+ const detail = await getIndicatorResultDetail(
+ ipqcId,
+ MesQcTypeEnum.IPQC,
+ indicatorResultId.value,
+ );
+ const detailMap = new Map(
+ (detail.items ?? []).map((item) => [item.indicatorId, item.id]),
+ );
+ indicatorRows.value.forEach((row) => {
+ const detailId = row.indicatorId
+ ? detailMap.get(row.indicatorId)
+ : undefined;
+ if (detailId) {
+ row.detailId = detailId;
+ }
+ });
+ await saveRowAttachments();
+}
+
+/** 瀛楀吀绫绘娴嬪�肩殑灞曠ず鏂囨 */
+function getIndicatorDisplay(row: IndicatorValueRow) {
+ if (!row.value) {
+ return '鏈~鍐�';
+ }
+ if (row.valueType === MesQcResultValueType.DICT) {
+ return (
+ getDictValueOptions(row.valueSpecification).find(
+ (option) => option.value === String(row.value),
+ )?.label ?? row.value
+ );
+ }
+ return row.value;
+}
const [Form, formApi] = useVbenForm({
commonConfig: {
@@ -73,6 +556,9 @@
await formApi.setFieldValue('status', formData.value.status);
formType.value = 'update';
}
+ // 妫�娴嬪�间笌宸ヨ祫瀛楁闅忔楠屽崟淇濆瓨
+ await saveIndicatorValues(formData.value.id!);
+ await saveWageFieldValues(formData.value.id!);
// 鍒锋柊蹇収锛堝凡甯︿笂 id / status锛夛紝涓嬫 finish 鐢ㄤ簬鍒ゆ柇鏄惁闇�瑕佸啀淇濆瓨
originalSnapshot.value = JSON.stringify(await formApi.getValues());
return true;
@@ -114,6 +600,9 @@
formData.value = { ...formData.value, ...data };
originalSnapshot.value = current;
}
+ // 妫�娴嬪��/宸ヨ祫瀛楁鍙兘鍙敼浜嗘槑缁嗭紝涓嶄綋鐜板湪涓昏〃鍗曞揩鐓ч噷
+ await saveIndicatorValues(id);
+ await saveWageFieldValues(id);
await finishIpqc(id);
message.success('瀹屾垚鎴愬姛');
await modalApi.close();
@@ -148,9 +637,17 @@
if (!isOpen) {
formData.value = undefined;
originalSnapshot.value = '';
+ resetResolvedScheme();
+ indicatorRows.value = [];
+ indicatorResultId.value = undefined;
+ wageFields.value = [];
return;
}
subTabsName.value = 'attachments';
+ resetResolvedScheme();
+ indicatorRows.value = [];
+ indicatorResultId.value = undefined;
+ wageFields.value = [];
// 鍔犺浇鏁版嵁
const data = modalApi.getData<{
formType: FormType;
@@ -158,7 +655,12 @@
prefill?: MesQcIpqcApi.Ipqc;
}>();
formType.value = data.formType;
- formApi.setState({ schema: useFormSchema(formType.value, formApi) });
+ formApi.setState({
+ schema: useFormSchema(formType.value, formApi, {
+ onWorkstationChange: handleWorkstationChange,
+ onProcessChange: handleProcessChange,
+ }),
+ });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {
@@ -167,6 +669,15 @@
formData.value = await getIpqc(data.id);
// 璁剧疆鍒� values
await formApi.setValues(formData.value);
+ // 缂栬緫/璇︽儏锛氭寜宸蹭繚瀛樼殑宸ュ簭甯﹀嚭榛樿璐ㄦ鏂规涓庢娴嬫寚鏍�
+ await resolveScheme(formData.value.processId);
+ // 宸蹭繚瀛樼殑妫�娴嬪�间紭鍏堝睍绀猴紱鍐嶆寜鏂规琛ラ綈鎸囨爣鍚嶇О銆佹爣鍑嗗�间笌鍗曚綅
+ await loadIndicatorValues(data.id);
+ if ((resolvedScheme.value?.indicators?.length ?? 0) > 0) {
+ enrichRowsFromScheme();
+ }
+ // 宸ヨ祫瀛楁锛氭寜宸ュ簭甯﹀嚭锛屽苟鍥炲~宸插~鍐欑殑鍊�
+ await loadWageFields(formData.value.processId, data.id);
} finally {
modalApi.unlock();
}
@@ -175,6 +686,9 @@
formData.value = { ...data.prefill };
// 璁剧疆鍒� values
await formApi.setValues(data.prefill);
+ await resolveScheme(data.prefill.processId);
+ buildRowsFromScheme();
+ await loadWageFields(data.prefill.processId);
}
originalSnapshot.value = JSON.stringify(await formApi.getValues());
},
@@ -184,6 +698,197 @@
<template>
<Modal :title="getTitle" class="w-4/5">
<Form class="mx-4" />
+ <div v-if="showSchemeCard" class="mx-4 mt-2">
+ <div class="rounded border border-gray-200 p-3">
+ <div class="mb-2 flex flex-wrap items-center gap-2 text-sm font-medium">
+ 璐ㄦ鏂规
+ <span v-if="resolvedScheme?.templateName" class="text-gray-500">
+ {{ resolvedScheme?.templateCode }} {{ resolvedScheme?.templateName }}
+ </span>
+ <span v-else-if="resolvingScheme" class="text-xs text-gray-400">
+ 姝e湪鎸夊伐浣嶆墍灞炲伐搴忚В鏋愨��
+ </span>
+ </div>
+ <Alert
+ v-if="!resolvedScheme?.indicators?.length"
+ type="warning"
+ show-icon
+ :message="
+ resolvedScheme?.templateId
+ ? '璇ュ伐搴忕殑榛樿璐ㄦ鏂规鏈淮鎶ゆ娴嬫寚鏍囷紝淇濆瓨鍚庝笉浼氱敓鎴愭楠岄」銆�'
+ : '璇ュ伐搴忔湭缁戝畾榛樿璐ㄦ鏂规锛屼繚瀛樺悗涓嶄細鐢熸垚妫�楠岄」锛涜鍒般�岃川閲忕鐞�-璐ㄦ鏂规 鈫� 閫傜敤宸ュ簭銆嶄腑缁存姢銆�'
+ "
+ />
+ <div class="mt-2 text-xs text-gray-400">
+ 榛樿鏂规鐢卞伐浣嶆墍灞炲伐搴忚嚜鍔ㄥ甫鍑猴紱濡傞渶鏇存崲锛屽彲鍦ㄣ�岃川妫�鏂规銆嶄腑鎵嬪伐閫夋嫨锛屼繚瀛樺悗鎸夋墍閫夋柟妗堢敓鎴愭楠岄」銆�
+ </div>
+ </div>
+ </div>
+ <div v-if="wageFields.length > 0" class="mx-4 mt-3">
+ <div class="rounded border border-gray-200 p-3">
+ <div class="mb-2 flex flex-wrap items-center gap-2 text-sm font-medium">
+ 宸ヨ祫瀛楁
+ <span class="text-xs font-normal text-gray-400">
+ 锛堝伐搴忚嚜瀹氫箟瀛楁锛岀敱璐ㄦ濉啓锛屼繚瀛樺悗鍙備笌璇ュ伐搴忔姤宸ュ伐璧勬牳绠楋級
+ </span>
+ </div>
+ <div class="grid grid-cols-1 gap-x-4 gap-y-3 md:grid-cols-2">
+ <div
+ v-for="row in wageFields"
+ :key="row.fieldId"
+ class="flex items-start gap-2"
+ >
+ <div class="w-40 shrink-0 pt-1 text-xs">
+ <div class="text-gray-700">{{ row.fieldName }}</div>
+ <div class="text-gray-400">
+ <span v-if="row.unit">鍗曚綅 {{ row.unit }}</span>
+ <span v-if="row.calcRole" class="ml-1">
+ 路 {{ WAGE_CALC_ROLE_LABEL[row.calcRole] }}
+ </span>
+ </div>
+ </div>
+ <div class="flex-1">
+ <div v-if="isDetail" class="pt-1 text-sm">
+ {{ getWageFieldDisplay(row) }}
+ </div>
+ <InputNumber
+ v-else-if="row.fieldType === WAGE_FIELD_TYPE_NUMBER"
+ v-model:value="row.valueNumber"
+ :precision="4"
+ class="!w-full"
+ placeholder="璇疯緭鍏�"
+ />
+ <Select
+ v-else-if="row.fieldType === WAGE_FIELD_TYPE_BOOLEAN"
+ v-model:value="row.value"
+ allow-clear
+ :options="[
+ { label: '鏄�', value: '1' },
+ { label: '鍚�', value: '0' },
+ ]"
+ placeholder="璇烽�夋嫨"
+ class="w-full"
+ />
+ <Input v-else v-model:value="row.value" placeholder="璇疯緭鍏�" />
+ </div>
+ </div>
+ </div>
+ <div class="mt-2 text-xs text-gray-400">
+ 鏈~鍐欑殑瀛楁鎸夊伐搴忎笂閰嶇疆鐨勫浐瀹氬�艰绠楋紱濉啓鍚庨殢妫�楠屽崟淇濆瓨锛屾姤宸ュ鎵规椂鐢ㄤ簬閲嶇畻宸ヨ祫銆�
+ </div>
+ </div>
+ </div>
+ <div class="mx-4 mt-3">
+ <div class="rounded border border-gray-200 p-3">
+ <div class="mb-2 flex flex-wrap items-center gap-2 text-sm font-medium">
+ 妫�楠屼俊鎭�
+ <span class="text-xs font-normal text-gray-400">
+ 锛堝彲鎵嬪伐澧炲垹妫�楠岃锛涜繃绋嬫楠屽彧涓婁紶闄勪欢锛屼笉濉啓妫�娴嬪�硷級
+ </span>
+ <Button
+ v-if="!isDetail"
+ class="ml-auto"
+ size="small"
+ type="primary"
+ ghost
+ @click="handleAddIndicator"
+ >
+ 娣诲姞妫�楠岄」
+ </Button>
+ </div>
+ <Table
+ v-if="indicatorRows.length > 0"
+ :data-source="indicatorRows"
+ :pagination="false"
+ bordered
+ row-key="indicatorId"
+ size="small"
+ >
+ <Table.Column title="妫�楠岄」" key="indicatorName" :width="180">
+ <template #default="{ record }">
+ <div class="text-gray-700">{{ record.indicatorName || '-' }}</div>
+ <div class="text-xs text-gray-400">
+ <template
+ v-if="
+ record.standardValue !== undefined &&
+ record.standardValue !== null
+ "
+ >
+ 鏍囧噯 {{ record.standardValue }}{{ record.unitText || '' }}
+ </template>
+ <template v-else-if="record.unitText">
+ 鍗曚綅 {{ record.unitText }}
+ </template>
+ </div>
+ </template>
+ </Table.Column>
+ <Table.Column title="妫�楠岄檮浠�" key="attachments">
+ <template #default="{ record }">
+ <div class="flex flex-col gap-1">
+ <div
+ v-for="file in record.files || []"
+ :key="file.id"
+ class="flex items-center gap-2 text-xs"
+ >
+ <a
+ :href="file.previewURL || file.downloadURL"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ {{ file.name }}
+ </a>
+ <Popconfirm
+ v-if="!isDetail"
+ title="纭绉婚櫎璇ユ楠岃闄勪欢锛�"
+ ok-text="绉婚櫎"
+ cancel-text="鍙栨秷"
+ @confirm="handleRowRemoveFile(record, file.id)"
+ >
+ <a class="text-red-500">绉婚櫎</a>
+ </Popconfirm>
+ </div>
+ <Upload
+ v-if="!isDetail"
+ :show-upload-list="false"
+ :before-upload="(file: File) => handleRowUpload(record, file)"
+ >
+ <Button size="small">涓婁紶闄勪欢</Button>
+ </Upload>
+ <span
+ v-if="isDetail && (record.files || []).length === 0"
+ class="text-xs text-gray-400"
+ >
+ 鏈笂浼犻檮浠�
+ </span>
+ </div>
+ </template>
+ </Table.Column>
+ <Table.Column
+ v-if="!isDetail"
+ title="鎿嶄綔"
+ key="actions"
+ :width="80"
+ >
+ <template #default="{ index }">
+ <a class="text-red-500" @click="handleRemoveIndicator(index)">
+ 鍒犻櫎
+ </a>
+ </template>
+ </Table.Column>
+ <template #emptyText>
+ <Empty description="鏆傛棤妫�楠岄」锛岃鐐瑰嚮銆屾坊鍔犳楠岄」銆�" />
+ </template>
+ </Table>
+ <Empty
+ v-else
+ :description="
+ resolvedScheme?.indicators?.length
+ ? '鏆傛棤妫�楠岄」锛岃鐐瑰嚮銆屾坊鍔犳楠岄」銆�'
+ : '璇ュ伐搴忔湭閰嶇疆妫�楠屾柟妗堬紝鏃犳硶娣诲姞妫�楠岄」'
+ "
+ />
+ </div>
+ </div>
<Tabs
v-if="formData?.id"
v-model:active-key="subTabsName"
--
Gitblit v1.9.3