From f10cf167372f2d8c4c0e14f42f361d7ab96d8347 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 03 七月 2026 13:59:00 +0800
Subject: [PATCH] Merge branch 'dev_pro2.0' of http://114.132.189.42:9002/r/mom-pro2-before into dev_pro2.0
---
src/views/mes/process-design/process/data.ts | 274 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 274 insertions(+), 0 deletions(-)
diff --git a/src/views/mes/process-design/process/data.ts b/src/views/mes/process-design/process/data.ts
new file mode 100644
index 0000000..d6ce88a
--- /dev/null
+++ b/src/views/mes/process-design/process/data.ts
@@ -0,0 +1,274 @@
+import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesProProcessApi } from '#/api/mes/pro/process';
+import type { MesProProcessContentApi } from '#/api/mes/pro/process/content';
+
+import { h } from 'vue';
+
+import {
+ CommonStatusEnum,
+ DICT_TYPE,
+ MesAutoCodeRuleCode,
+} from '../../../../packages/constants/src';
+import { getDictOptions } from '../../../../packages/effects/hooks/src';
+
+import { Button } from 'ant-design-vue';
+
+import { z } from '#/adapter/form';
+import { generateAutoCode } from '#/api/mes/md/autocode/record';
+
+/** 琛ㄥ崟绫诲瀷 */
+export type FormType = 'create' | 'detail' | 'update';
+
+/** 鏂板/淇敼鐢熶骇宸ュ簭鐨勮〃鍗� */
+export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'id',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'code',
+ label: '宸ュ簭缂栫爜',
+ component: 'Input',
+ componentProps: {
+ maxLength: 64,
+ placeholder: '璇疯緭鍏ュ伐搴忕紪鐮�',
+ },
+ rules: z.string().min(1, '宸ュ簭缂栫爜涓嶈兘涓虹┖').max(64),
+ suffix: () =>
+ h(
+ Button,
+ {
+ type: 'default',
+ onClick: async () => {
+ const code = await generateAutoCode(
+ MesAutoCodeRuleCode.PRO_PROCESS_CODE,
+ );
+ await formApi?.setFieldValue('code', code);
+ },
+ },
+ { default: () => '鐢熸垚' },
+ ),
+ },
+ {
+ fieldName: 'name',
+ label: '宸ュ簭鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ maxLength: 100,
+ placeholder: '璇疯緭鍏ュ伐搴忓悕绉�',
+ },
+ rules: z.string().min(1, '宸ュ簭鍚嶇О涓嶈兘涓虹┖').max(100),
+ },
+ {
+ fieldName: 'status',
+ label: '鐘舵��',
+ component: 'RadioGroup',
+ componentProps: {
+ buttonStyle: 'solid',
+ optionType: 'button',
+ options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
+ },
+ rules: z.number().default(CommonStatusEnum.ENABLE),
+ },
+ {
+ fieldName: 'attention',
+ label: '宸ュ簭璇存槑',
+ component: 'Textarea',
+ formItemClass: 'col-span-3',
+ componentProps: {
+ maxLength: 500,
+ placeholder: '璇疯緭鍏ュ伐搴忚鏄�',
+ rows: 3,
+ },
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ formItemClass: 'col-span-3',
+ componentProps: {
+ maxLength: 250,
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 3,
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'code',
+ label: '宸ュ簭缂栫爜',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ュ伐搴忕紪鐮�',
+ },
+ },
+ {
+ fieldName: 'name',
+ label: '宸ュ簭鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ュ伐搴忓悕绉�',
+ },
+ },
+ {
+ fieldName: 'status',
+ label: '鐘舵��',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
+ placeholder: '璇烽�夋嫨鐘舵��',
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<MesProProcessApi.Process>['columns'] {
+ return [
+ {
+ field: 'code',
+ title: '宸ュ簭缂栫爜',
+ minWidth: 150,
+ slots: {
+ default: 'code',
+ },
+ },
+ { field: 'name', title: '宸ュ簭鍚嶇О', minWidth: 180 },
+ {
+ field: 'status',
+ title: '鐘舵��',
+ width: 100,
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.COMMON_STATUS },
+ },
+ },
+ { field: 'remark', title: '澶囨敞', minWidth: 180 },
+ {
+ field: 'createTime',
+ title: '鍒涘缓鏃堕棿',
+ width: 180,
+ formatter: 'formatDateTime',
+ },
+ {
+ title: '鎿嶄綔',
+ width: 150,
+ fixed: 'right',
+ slots: {
+ default: 'actions',
+ },
+ },
+ ];
+}
+
+/** 宸ュ簭鍐呭锛堟搷浣滄楠わ級琛ㄥ崟 */
+export function useContentFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'id',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'processId',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'sort',
+ label: '搴忓彿',
+ component: 'InputNumber',
+ componentProps: {
+ class: '!w-full',
+ max: 999,
+ min: 1,
+ precision: 0,
+ },
+ rules: z.number().default(1),
+ },
+ {
+ fieldName: 'content',
+ label: '姝ラ璇存槑',
+ component: 'Textarea',
+ componentProps: {
+ maxLength: 500,
+ placeholder: '璇疯緭鍏ユ楠よ鏄�',
+ rows: 3,
+ },
+ },
+ {
+ fieldName: 'device',
+ label: '杈呭姪璁惧',
+ component: 'Input',
+ componentProps: {
+ maxLength: 100,
+ placeholder: '璇疯緭鍏ヨ緟鍔╄澶�',
+ },
+ },
+ {
+ fieldName: 'material',
+ label: '杈呭姪鏉愭枡',
+ component: 'Input',
+ componentProps: {
+ maxLength: 100,
+ placeholder: '璇疯緭鍏ヨ緟鍔╂潗鏂�',
+ },
+ },
+ {
+ fieldName: 'docUrl',
+ label: '鏉愭枡鏂囨。 URL',
+ component: 'Input',
+ componentProps: {
+ maxLength: 250,
+ placeholder: '璇疯緭鍏ユ潗鏂欐枃妗� URL',
+ },
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ componentProps: {
+ maxLength: 250,
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 2,
+ },
+ },
+ ];
+}
+
+/** 宸ュ簭鍐呭鍒楄〃鐨勫瓧娈� */
+export function useContentGridColumns(): VxeTableGridOptions<MesProProcessContentApi.ProcessContent>['columns'] {
+ return [
+ { field: 'sort', title: '搴忓彿', width: 80, align: 'center' },
+ { field: 'content', title: '姝ラ璇存槑', minWidth: 220 },
+ { field: 'device', title: '杈呭姪璁惧', width: 150 },
+ { field: 'material', title: '杈呭姪鏉愭枡', width: 150 },
+ { field: 'docUrl', title: '鏉愭枡鏂囨。', minWidth: 180 },
+ { field: 'remark', title: '澶囨敞', minWidth: 160 },
+ {
+ title: '鎿嶄綔',
+ width: 130,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
--
Gitblit v1.9.3