柏杨
authored
|
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
|
<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: '',
|
柏杨
authored
|
44
|
rules: [{ required: true }],
|
柏杨
authored
|
45
46
47
48
49
50
51
52
|
},
{
field: 'configSample',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
|
柏杨
authored
|
53
|
label: '确认样品确认状态(填写邮箱,请用逗号隔开)',
|
柏杨
authored
|
54
55
|
rules: [{ required: true }],
},
|
柏杨
authored
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
{
field: 'otherSample',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '其他需求样品发送时间(填写邮箱)',
rules: [{ required: true }],
},
{
field: 'bigSample',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '大货样确认意见(填写邮箱)',
rules: [{ required: true }],
},
|
柏杨
authored
|
76
77
78
79
80
81
82
83
84
85
|
{
field: 'aitexSgsTest',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: 'AITEX/SGS测试状态(填写邮箱)',
rules: [{ required: true }],
},
|
柏杨
authored
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
{
field: 'barcodeArrival',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '要求包装到货日期(填写邮箱)',
rules: [{ required: true }],
},
{
field: 'latestDc',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '最晚订舱时间(填写邮箱)',
rules: [{ required: true }],
},
|
柏杨
authored
|
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
|
{
field: 'endCheckDate',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '尾期验货日期(填写邮箱)',
rules: [{ required: true }],
},
{
field: 'midCheckReport',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '中期验货报告(填写邮箱)',
rules: [{ required: true }],
},
{
field: 'endCheckReport',
component: 'InputTextArea',
labelWidth: 250,
colProps: {
span: 23,
},
label: '尾期验货报告(填写邮箱)',
rules: [{ required: true }],
},
|
柏杨
authored
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
{
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 });
setFieldsValue({
...toRaw(data.data),
});
});
|
柏杨
authored
|
160
|
//获取现有的列表
|
柏杨
authored
|
161
162
163
164
|
async function getData() {
const emailAll = await getEmailList({});
return emailAll;
}
|
柏杨
authored
|
165
166
167
168
169
170
|
interface NewValues {
id: string;
type: string;
typeValue: string;
configInfos: any[];
}
|
柏杨
authored
|
171
|
//完成编辑
|
柏杨
authored
|
172
173
174
|
async function handleSubmit() {
try {
const values = await validate();
|
柏杨
authored
|
175
176
177
178
179
180
|
const newValues = ref<NewValues>({
id: '',
type: '',
typeValue: '',
configInfos: [],
});
|
柏杨
authored
|
181
|
//将编辑后的值赋值给新对象
|
柏杨
authored
|
182
183
184
|
newValues.value.id = values.id;
newValues.value.type = values.type;
newValues.value.typeValue = values.typeValue;
|
柏杨
authored
|
185
186
|
//获取所有数据
//找出需要修改的数据,并将修改后的configInfos赋值给新对象
|
柏杨
authored
|
187
188
|
getData().then((res) => {
for (const value1 of res) {
|
柏杨
authored
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
//循环整个列表,找出编辑行
if (value1.id == values.id) {
// test.value = value1;
newValues.value.configInfos = value1.configInfos;
for (const value2 of newValues.value.configInfos) {
//遍历所有邮件事件
for (const value3 in values) {
//遍历编辑框传递数据
if (value2.fieldValue == value3) {
const arr: string[] = values[value3].split(/[,|,]/);
value2.emails = arr;
}
}
}
|
柏杨
authored
|
203
204
205
|
}
}
emit('success', {
|
柏杨
authored
|
206
|
values: { ...newValues.value },
|
柏杨
authored
|
207
208
209
210
211
212
213
214
215
|
});
});
setDrawerProps({ confirmLoading: true });
closeDrawer();
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>
|