From 91c82965b2d987452ca276e3a03b48c8dcda2ae9 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 19 八月 2026 11:47:26 +0800
Subject: [PATCH] config(env): 更新生产环境配置和公司名称
---
src/views/mes/pro/task/data.ts | 165 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 112 insertions(+), 53 deletions(-)
diff --git a/src/views/mes/pro/task/data.ts b/src/views/mes/pro/task/data.ts
index aeef143..aeb9868 100644
--- a/src/views/mes/pro/task/data.ts
+++ b/src/views/mes/pro/task/data.ts
@@ -1,40 +1,47 @@
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import { z } from '#/adapter/form';
+import { getSimpleUserListByRoleCode } from '#/api/system/user';
import type { MesProTaskApi } from '#/api/mes/pro/task';
import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
+import type { Ref } from 'vue';
+
import { markRaw } from 'vue';
-import { DICT_TYPE } from '../../../../packages/constants/src';
-import { getDictOptions } from '../../../../packages/effects/hooks/src';
+import { DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+import { message } from 'ant-design-vue';
+
+import CrmCustomerSelect from '#/components/crm-customer-select.vue';
+import { calculateTaskDuration } from '#/api/mes/pro/task';
import { getRangePickerDefaultProps } from '#/utils';
-import { MdClientSelect } from '#/views/mes/md/client/components';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { MdWorkstationSelect } from '#/views/mes/md/workstation/components';
import { ProProcessSelect } from '#/views/mes/process-design/process/components';
import { RouteColorPicker } from '#/views/mes/process-design/route/components';
import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
-/** 寰呮帓浜у伐鍗曞垪琛ㄧ殑鎼滅储琛ㄥ崟 */
+/** 寰呮帓浜ц鍗曞垪琛ㄧ殑鎼滅储琛ㄥ崟 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'code',
- label: '宸ュ崟缂栫爜',
+ label: '璁㈠崟缂栫爜',
component: 'Input',
componentProps: {
allowClear: true,
- placeholder: '璇疯緭鍏ュ伐鍗曠紪鐮�',
+ placeholder: '璇疯緭鍏ヨ鍗曠紪鐮�',
},
},
{
fieldName: 'name',
- label: '宸ュ崟鍚嶇О',
+ label: '璁㈠崟鍚嶇О',
component: 'Input',
componentProps: {
allowClear: true,
- placeholder: '璇疯緭鍏ュ伐鍗曞悕绉�',
+ placeholder: '璇疯緭鍏ヨ鍗曞悕绉�',
},
},
{
@@ -57,7 +64,7 @@
{
fieldName: 'clientId',
label: '瀹㈡埛',
- component: markRaw(MdClientSelect),
+ component: markRaw(CrmCustomerSelect),
componentProps: {
placeholder: '璇烽�夋嫨瀹㈡埛',
},
@@ -74,12 +81,12 @@
];
}
-/** 寰呮帓浜у伐鍗曞垪琛ㄧ殑瀛楁 */
+/** 寰呮帓浜ц鍗曞垪琛ㄧ殑瀛楁 */
export function useGridColumns(): VxeTableGridOptions<MesProWorkOrderApi.WorkOrder>['columns'] {
return [
{
field: 'code',
- title: '宸ュ崟缂栫爜',
+ title: '璁㈠崟缂栫爜',
fixed: 'left',
width: 200,
treeNode: true,
@@ -87,12 +94,12 @@
},
{
field: 'name',
- title: '宸ュ崟鍚嶇О',
+ title: '璁㈠崟鍚嶇О',
minWidth: 150,
},
{
field: 'orderSourceType',
- title: '宸ュ崟鏉ユ簮',
+ title: '璁㈠崟鏉ユ簮',
width: 100,
cellRender: {
name: 'CellDict',
@@ -125,15 +132,33 @@
width: 80,
},
{
- field: 'quantity',
- title: '宸ュ崟鏁伴噺',
+ field: 'status',
+ title: '璁㈠崟鐘舵��',
width: 100,
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.MES_PRO_WORK_ORDER_STATUS },
+ },
},
{
- field: 'quantityChanged',
- title: '璋冩暣鏁伴噺',
+ field: 'productionStatus',
+ title: '鐢熶骇鐘舵��',
+ width: 100,
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.ORDER_PRODUCTION_STATUS },
+ },
+ },
+ {
+ field: 'quantity',
+ title: '璁㈠崟鏁伴噺',
width: 100,
},
+ // {
+ // field: 'quantityChanged',
+ // title: '璋冩暣鏁伴噺',
+ // width: 100,
+ // },
{
field: 'quantityProduced',
title: '宸茬敓浜ф暟閲�',
@@ -155,30 +180,22 @@
width: 120,
formatter: 'formatDate',
},
- {
- field: 'status',
- title: '鎺掍骇鐘舵��',
- width: 100,
- cellRender: {
- name: 'CellDict',
- props: { type: DICT_TYPE.MES_PRO_WORK_ORDER_STATUS },
- },
- },
+
{
title: '鎿嶄綔',
- width: 100,
+ width: 160,
fixed: 'right',
slots: { default: 'actions' },
},
];
}
-/** 鎺掍骇瀵硅瘽妗嗗彧璇诲伐鍗曚俊鎭殑琛ㄥ崟 */
+/** 鎺掍骇瀵硅瘽妗嗗彧璇昏鍗曚俊鎭殑琛ㄥ崟 */
export function useScheduleFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'code',
- label: '宸ュ崟缂栫爜',
+ label: '璁㈠崟缂栫爜',
component: 'Input',
componentProps: {
disabled: true,
@@ -186,7 +203,7 @@
},
{
fieldName: 'name',
- label: '宸ュ崟鍚嶇О',
+ label: '璁㈠崟鍚嶇О',
component: 'Input',
componentProps: {
disabled: true,
@@ -194,7 +211,7 @@
},
{
fieldName: 'orderSourceType',
- label: '宸ュ崟鏉ユ簮',
+ label: '璁㈠崟鏉ユ簮',
component: 'Select',
componentProps: {
disabled: true,
@@ -214,7 +231,7 @@
},
{
fieldName: 'type',
- label: '宸ュ崟绫诲瀷',
+ label: '璁㈠崟绫诲瀷',
component: 'Select',
componentProps: {
disabled: true,
@@ -247,7 +264,7 @@
},
{
fieldName: 'quantity',
- label: '宸ュ崟鏁伴噺',
+ label: '璁㈠崟鏁伴噺',
component: 'InputNumber',
componentProps: {
class: '!w-full',
@@ -258,7 +275,7 @@
{
fieldName: 'clientId',
label: '瀹㈡埛',
- component: markRaw(MdClientSelect),
+ component: markRaw(CrmCustomerSelect),
componentProps: {
disabled: true,
},
@@ -279,12 +296,12 @@
class: '!w-full',
disabled: true,
format: 'YYYY-MM-DD',
- valueFormat: 'x',
+ valueFormat: 'YYYY-MM-DD',
},
},
{
fieldName: 'status',
- label: '宸ュ崟鐘舵��',
+ label: '璁㈠崟鐘舵��',
component: 'Select',
componentProps: {
disabled: true,
@@ -347,8 +364,8 @@
},
{
field: 'duration',
- title: '鐢熶骇鏃堕暱',
- width: 80,
+ title: '鐢熶骇鏃堕暱(h)',
+ width: 120,
},
{
field: 'endTime',
@@ -376,7 +393,7 @@
}
/** 鐢熶骇浠诲姟鏂板/淇敼鐨勮〃鍗� */
-export function useTaskFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
+export function useTaskFormSchema(formApi?: VbenFormApi, workOrderQuantity?: Ref<number | undefined>): VbenFormSchema[] {
return [
{
fieldName: 'workstationId',
@@ -384,6 +401,7 @@
component: markRaw(MdWorkstationSelect),
componentProps: {
placeholder: '璇烽�夋嫨宸ヤ綔绔�',
+ onChange: () => recalcDuration(formApi),
},
rules: 'selectRequired',
},
@@ -391,11 +409,13 @@
fieldName: 'quantity',
label: '鎺掍骇鏁伴噺',
component: 'InputNumber',
+ description: () => workOrderQuantity?.value != null ? `璁㈠崟鏁伴噺锛�${workOrderQuantity.value}` : '',
componentProps: {
class: '!w-full',
min: 0.01,
placeholder: '璇疯緭鍏ユ帓浜ф暟閲�',
precision: 2,
+ onChange: () => recalcDuration(formApi),
},
rules: 'required',
},
@@ -410,17 +430,23 @@
component: 'DatePicker',
componentProps: {
class: '!w-full',
- placeholder: '璇烽�夋嫨寮�濮嬫椂闂�',
+ placeholder: '璇峰厛閫夋嫨宸ヤ綔绔�',
showTime: true,
- valueFormat: 'x',
- // 寮�濮嬫椂闂村彉鏇达細閲嶆柊璁$畻缁撴潫鏃堕棿
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
onChange: () => recalcEndTime(formApi),
+ },
+ dependencies: {
+ triggerFields: ['workstationId'],
+ componentProps: (values) => ({
+ disabled: !values.workstationId,
+ placeholder: values.workstationId ? '璇烽�夋嫨寮�濮嬫椂闂�' : '璇峰厛閫夋嫨宸ヤ綔绔�',
+ }),
},
rules: 'required',
},
{
fieldName: 'duration',
- label: '鐢熶骇鏃堕暱',
+ label: '鐢熶骇鏃堕暱(h)',
component: 'InputNumber',
componentProps: {
class: '!w-full',
@@ -440,8 +466,22 @@
class: '!w-full',
disabled: true,
showTime: true,
- valueFormat: 'x',
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
+ },
+ {
+ fieldName: 'assigneeUserIds',
+ label: '鎶ュ伐浜�',
+ component: 'ApiSelect',
+ componentProps: {
+ placeholder: '璇烽�夋嫨鎶ュ伐浜�',
+ api: getSimpleUserListByRoleCode,
+ params: { code: 'production_submit_work' },
+ labelField: 'nickname',
+ valueField: 'id',
+ mode: 'multiple',
+ },
+ rules: z.array(z.number()).min(1, '璇烽�夋嫨鎶ュ伐浜�').default([]),
},
{
fieldName: 'remark',
@@ -456,18 +496,37 @@
];
}
-/** 璁$畻缁撴潫鏃堕棿锛氬紑濮嬫椂闂� + 鐢熶骇鏃堕暱 脳 8 灏忔椂 */
+/** 閫夋嫨宸ヤ綔绔欐垨淇敼鏁伴噺鍚庯紝鑷姩璁$畻鐢熶骇鏃堕暱 */
+async function recalcDuration(formApi?: VbenFormApi) {
+ if (!formApi) return;
+ const values = await formApi.getValues();
+ if (!values.workstationId || !values.quantity) return;
+ try {
+ const res = await calculateTaskDuration(values.workstationId, values.quantity);
+ await formApi.setFieldValue('duration', res.duration);
+ if (res.duration === 0) {
+ message.warning('璇ュ伐浣滅珯鏈粦瀹氳澶囷紝鎴栫粦瀹氳澶囨湭閰嶇疆鐢熶骇鏁堢巼');
+ }
+ // 閲嶆柊璁$畻缁撴潫鏃堕棿
+ await recalcEndTime(formApi);
+ } catch {
+ // 璁$畻澶辫触涓嶉樆濉炵敤鎴锋搷浣�
+ }
+}
+
+/** 璁$畻缁撴潫鏃堕棿锛氬紑濮嬫椂闂� + 鐢熶骇鏃堕暱锛堝皬鏃讹級 */
async function recalcEndTime(formApi?: VbenFormApi) {
if (!formApi) {
return;
}
const values = await formApi.getValues();
if (values.startTime && values.duration) {
- const start = Number(values.startTime);
- await formApi.setFieldValue(
- 'endTime',
- start + values.duration * 8 * 3600 * 1000,
- );
+ const start = new Date(values.startTime).getTime();
+ const endTime = start + values.duration * 3600 * 1000;
+ const pad = (n: number) => String(n).padStart(2, '0');
+ const d = new Date(endTime);
+ const formatted = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
+ await formApi.setFieldValue('endTime', formatted);
}
}
@@ -476,11 +535,11 @@
return [
{
fieldName: 'workOrderId',
- label: '鐢熶骇宸ュ崟',
+ label: '鐢熶骇璁㈠崟',
component: markRaw(ProWorkOrderSelect),
componentProps: {
allowClear: true,
- placeholder: '璇烽�夋嫨鐢熶骇宸ュ崟',
+ placeholder: '璇烽�夋嫨鐢熶骇璁㈠崟',
},
},
{
@@ -553,7 +612,7 @@
width: 170,
formatter: 'formatDateTime',
},
- { field: 'duration', title: '鐢熶骇鏃堕暱', width: 100 },
+ { field: 'duration', title: '鐢熶骇鏃堕暱(h)', width: 120 },
{
field: 'endTime',
title: '棰勮瀹屾垚鏃堕棿',
--
Gitblit v1.9.3