DrawerEdit.vue
5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<template>
<BasicDrawer
v-cloakv-bind="$attrs"
@register="register"
title="新增邮件发送"
width="35%"
showFooter
@ok="handleSubmit"
ref="formRef"
okText="保存"
:destroyOnClose="true"
:isDetail="true"
:showDetailBack="false"
:mask="false"
class="z-20"
>
<div>
<BasicForm @register="registerForm" />
</div>
<!-- <div>客户编码</div>
<textarea></textarea> -->
</BasicDrawer>
</template>
<script lang="ts" setup>
import { BasicDrawer, useDrawerInner } from '@/components/Drawer';
import { BasicForm, FormSchema, useForm } from '@/components/Form';
import { defineComponent, ref, computed, unref, toRaw, reactive } from 'vue';
import { getEmailList } from '/@/api/sys/config';
const emit = defineEmits(['success']);
// const isUpdate = ref(true);
const schemas: FormSchema[] = [
{
field: 'typeValue',
component: 'Select',
label: '客户编码',
componentProps: {
disabled: 'Select',
},
colProps: {
span: 23,
},
defaultValue: '',
},
{
field: 'configSample',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '确认样品确认状态(填写邮箱)',
rules: [{ required: true }],
},
// {
// field: 'event',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '确认样品确认状态(填写邮箱)',
// rules: [{ required: true }],
// },
// {
// field: 'event2',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '其他需求样品发送时间(填写邮箱)',
// rules: [{ required: true }],
// },
// {
// field: 'event3',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '大货样确认意见(填写邮箱)',
// rules: [{ required: true }],
// },
{
field: 'aitexSgsTest',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: 'AITEX/SGS测试状态(填写邮箱)',
rules: [{ required: true }],
},
// {
// field: 'event5',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '要求包装到货日期(填写邮箱)',
// rules: [{ required: true }],
// },
// {
// field: 'event6',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '最晚订舱时间(填写邮箱)',
// rules: [{ required: true }],
// },
// {
// field: 'event7',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '尾期验货日期(填写邮箱)',
// rules: [{ required: true }],
// },
// {
// field: 'event8',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '中期验货报告(填写邮箱)',
// rules: [{ required: true }],
// },
// {
// field: 'event9',
// component: 'InputTextArea',
// labelWidth: 250,
// colProps: {
// span: 23,
// },
// label: '尾期验货报告(填写邮箱)',
// rules: [{ required: true }],
// },
{
field: 'id',
},
{
field: 'type',
},
];
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
labelWidth: 120,
schemas,
layout: 'vertical',
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
// 方式1
resetFields();
setDrawerProps({ confirmLoading: false });
console.log(data.data, 666);
// setFieldsValue({
// settingValue: data.data.settingValue,
// enableFlag: data.data.enableFlag,
// // settingValue: data.info,
// });
setFieldsValue({
...toRaw(data.data),
});
});
function replaceChineseCommas(text: string): string {
// 使用正则表达式替换中文逗号
const replacedText = text.replace(/,/g, ',');
return replacedText;
}
async function getData() {
const emailAll = await getEmailList({});
console.log(emailAll, 56561);
return emailAll;
}
async function handleSubmit() {
try {
const values = await validate();
getData().then((res) => {
const test = ref();
for (const value1 of res) {
test.value = value1;
for (const value2 of value1.configInfos) {
console.log(value1, 56568);
}
}
test.value.configSample = replaceChineseCommas(values.configSample);
emit('success', {
values: { ...test },
});
});
// values.aitexSgsTest = replaceChineseCommas(values.aitexSgsTest);
// console.log(values, 333333);
// emit('success', {
// values: { ...values },
// });
setDrawerProps({ confirmLoading: true });
closeDrawer();
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>