ProductText.vue
6.14 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
213
214
215
216
217
218
<template>
<!-- <BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="生产指标书"
width="500px"
:height="80"
wrapClassName="h-[340px]"
@visible-change="handleShow"
:footer="null"
> -->
<BasicModal
v-bind="$attrs"
destroyOnClose
@register="register"
title="生产指标书"
width="500px"
@visible-change="handleShow"
:footer="null"
:bodyStyle="{ height: '180px' }"
>
<div class="container">
<div v-if="isShow1 == true" style="margin-top: 50px; text-align: center">
<RadioGroup v-model:value="choose" :options="options" />
</div>
<div class="showPdf" v-if="isShow2 == true" style="margin-top: 35px; text-align: center">
<!-- <img src="/pdf.png" /> -->
<FilePptOutlined :style="{ fontSize: '20px' }" class="FilePptOutlined" />
<div style="margin-top: 1px; margin-left: 10px">生产指标书</div>
<EyeOutlined :style="{ fontSize: '20px' }" class="EyeOutlined" @click="handlePdf" />
</div>
<div class="bottom">
<a-button type="primary" @click="handleProduct" className="ml-4" v-if="isShow1 == true"
>生成</a-button
>
<a-button
type="primary"
@click="handleExport"
className="ml-4"
:loading="exportLoading"
v-if="isShow1 == false"
>发送</a-button
>
<a-button type="primary" @click="handleCancel" className="ml-4" style="margin-left: 6px"
>取消</a-button
>
</div>
</div>
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed, onMounted, onUpdated } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { RadioGroup } from 'ant-design-vue';
import { EyeOutlined, FilePptOutlined } from '@ant-design/icons-vue';
import { useMessage } from '@/hooks/web/useMessage';
export default defineComponent({
props: {
role: {
type: String,
},
customerCodes: {
type: Array<string | number>,
},
},
components: { BasicModal, RadioGroup, EyeOutlined, FilePptOutlined },
setup(props) {
const loading = ref(true);
const exportLoading = ref(false);
const info = ref();
const choose = ref(); //选择公司
const isShow1 = ref(true); //选择公司页面
const isShow2 = ref(false); //生成PDF页面
const pdf = ref(['/pdf.png']);
const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
// if (data.customers.length == 0) {
// error('请选择订单');
// closeModal();
// }
});
const options = computed(() => {
// 运营总监-基本信息,跟单,质检
return [
{ label: '青岛翱特逸格饰品有限公司', value: '1' },
{ label: ' 青岛吉庆天成饰品有限公司', value: '2' },
];
});
const { createMessage } = useMessage();
const { error } = createMessage;
const customerCodeToCompanyMap: Record<string, string> = {
A01: '1',
A04: '2',
A05: '2',
A06: '1',
A07: '2',
A08: '1',
A09: '1',
A10: '1',
A11: '1',
M03: '2',
M05: '2',
};
function handleCancel() {
loading.value = true;
choose.value = '';
setModalProps({ loading: false, confirmLoading: false });
isShow1.value = true;
isShow2.value = false;
closeModal();
}
function handleShow(visible: boolean) {
if (visible) {
loading.value = true;
choose.value = '';
setModalProps({ loading: false, confirmLoading: false });
isShow1.value = true;
isShow2.value = false;
}
}
function validateCompany(selectedCodes: any, company: string): boolean {
for (const [customerCode] of selectedCodes) {
const mappedCompany = customerCodeToCompanyMap[customerCode];
if (mappedCompany === undefined) {
// 如果 customerCode 不在 customerCodeToCompanyMap 中,跳过
console.warn(`Customer code ${customerCode} not found in the mapping, skipping.`);
continue;
}
if (mappedCompany !== company) {
// 如果有一个不匹配,返回 false
return false;
}
}
// 如果所有匹配,返回 true
return true;
}
//生成pdf
// const customerCodeList: string[] = props.customerCodes;
function handleProduct() {
const customerCodeList = props.customerCodes;
const areValid = validateCompany(customerCodeList, choose.value);
//如果选错了,弹出提示
if (!areValid) {
error('勾选订单与选择的公司不匹配');
} else {
if (choose.value == '1' || choose.value == '2') {
//此处设置接口,传递选择的公司值
isShow1.value = false;
isShow2.value = true;
}
}
}
//查看pdf
function handlePdf() {
// const pdfUrl = './pdfs.pdf';
// window.open(pdfUrl, '_blank');
}
//发送按钮
async function handleExport() {
closeModal();
}
return {
register,
loading,
choose,
handleShow,
handleCancel,
info,
handleExport,
handleProduct,
handlePdf,
exportLoading,
isShow1,
isShow2,
options,
pdf,
};
},
});
</script>
<style scoped>
/* .container {
position: relative;
}
.bottom {
position: absolute;
bottom: 0;
} */
.container {
display: flex;
flex-direction: column;
min-height: 20vh;
}
.bottom {
margin-top: auto;
margin-left: auto;
margin-right: 20px;
}
.showPdf {
border: 2px solid;
border-color: #d8d8d8;
border-radius: 5px;
height: 30px;
position: relative;
display: flex;
}
.FilePptOutlined {
margin-top: 3px;
margin-left: 30px;
}
.EyeOutlined {
margin-top: 3px;
margin-left: 290px;
}
</style>