3131 >
3232 </div >
3333 <div class =" form-group" >
34- <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >出发站拼音(全小写) </label >
34+ <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >出发站拼音</label >
3535 <input
3636 v-model =" form.fromPinyin"
3737 type =" text"
5353 >
5454 </div >
5555 <div class =" form-group" >
56- <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >到达站拼音(全小写) </label >
56+ <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >到达站拼音</label >
5757 <input
5858 v-model =" form.toPinyin"
5959 type =" text"
122122 <option value =" 二等座" >二等座</option >
123123 <option value =" 商务座" >商务座</option >
124124 <option value =" 无座" >无座</option >
125+ <!-- 新增卧铺类型 -->
126+ <option value =" 硬座" >硬座</option >
127+ <option value =" 软座" >软座</option >
128+ <option value =" 特等座" >特等座</option >
129+ <option value =" 软卧" >软卧</option >
130+ <option value =" 硬卧" >硬卧</option >
131+ <option value =" 动卧" >动卧</option >
132+ <option value =" 高级软卧" >高级软卧</option >
133+ <option value =" 一等卧" >一等卧</option >
134+ <option value =" 二等卧" >二等卧</option >
125135 </select >
126136 </div >
127137 </div >
148158 required
149159 >
150160 </div >
161+ <!-- 铺位类型选择(卧铺专用,上/中/下) -->
162+ <!-- 铺位类型(卧铺专用,上/中/下铺选择) -->
163+ <div class =" form-group" v-if =" sleeperTypes.includes(form.seatType)" >
164+ <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >铺位类型</label >
165+ <select
166+ v-model =" form.berthType"
167+ class =" w-full px-4 py-3 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all appearance-none"
168+ required
169+ >
170+ <option value =" " >选择铺位</option >
171+ <option value =" 上" >上铺</option >
172+ <option value =" 中" >中铺</option >
173+ <option value =" 下" >下铺</option >
174+ </select >
175+ </div >
151176 <div class =" form-group" >
152- <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >座位号</label >
177+ <label v-if =" sleeperTypes.includes(form.seatType)" class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >铺位号</label >
178+ <label v-else class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >座位号</label >
153179 <input
154180 v-model =" form.seatNumber"
155181 type =" text"
162188 </div >
163189 <div class =" form-group" >
164190 <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >票价(元)</label >
165- <input
166- v-model =" form.price"
167- type =" number"
168- step =" 0.5"
191+ <input
192+ v-model =" form.price"
193+ type =" number"
194+ step =" 0.5"
169195 min =" 0"
170196 class =" w-full px-4 py-3 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
171197 placeholder =" 例:443.5"
175201 </div >
176202 <div class =" form-group" >
177203 <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >票号</label >
178- <input
179- v-model =" form.serial"
180- type =" text"
204+ <input
205+ v-model =" form.serial"
206+ type =" text"
181207 class =" w-full px-4 py-3 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
182208 placeholder =" 例:283K104567"
183209 required
184210 >
185211 </div >
212+ <!-- 座位/价格信息区域 - 新增优惠类型选择 -->
213+ <div class =" form-group" >
214+ <label class =" block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1" >优惠类型</label >
215+ <select
216+ v-model =" form.discountType"
217+ class =" w-full px-4 py-3 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all appearance-none"
218+ >
219+ <option value =" " >无优惠</option >
220+ <option value =" student" >学生票(学+惠)</option >
221+ <option value =" child" >儿童票(儿)</option >
222+ <option value =" military" >残疾军人票(军)</option >
223+ <option value =" disabled" >残疾人票(残)</option >
224+ <option value =" elder" >老人优惠票(老)</option >
225+ <option value =" discount" >普通优惠票(惠)</option >
226+ <option value =" group" >团体票(团)</option >
227+ <option value =" worker-group" >务工团体票(工)</option >
228+ <option value =" student-group" >学生团体票(学+团)</option >
229+ </select >
230+ </div >
186231 </div >
187232 </div >
188233
263308 :dateTime =" form.dateTime"
264309 :carriage =" form.carriage"
265310 :seatNumber =" form.seatNumber"
311+ :berthType =" form.berthType"
266312 :price =" form.price"
267313 :seatType =" form.seatType"
268314 :idNumber =" form.idNumber"
269315 :passengerName =" form.passengerName"
270316 :footerInfo =" form.footerInfo"
317+ :discountType =" form.discountType"
271318 />
272319 </div >
273320 <!-- 隐藏的原始尺寸车票,用于导出 -->
287334 :dateTime =" form.dateTime"
288335 :carriage =" form.carriage"
289336 :seatNumber =" form.seatNumber"
337+ :berthType =" form.berthType"
290338 :price =" form.price"
291339 :seatType =" form.seatType"
292340 :idNumber =" form.idNumber"
293341 :passengerName =" form.passengerName"
294342 :footerInfo =" form.footerInfo"
343+ :discountType =" form.discountType"
295344 />
296345 </div >
297346 </div >
302351
303352
304353<script setup>
305- import { ref , reactive , onMounted , nextTick } from ' vue' ;
354+ import { ref , reactive , onMounted , nextTick , watch , computed } from ' vue' ;
306355import TrainTicket from ' @/components/TrainTicket.vue' ;
307- import html2canvas from ' html2canvas' ;
308356import { toPng } from " html-to-image" ;
309357
310358
@@ -324,7 +372,38 @@ const form = reactive({
324372 seatType: ' 一等座' ,
325373 idNumber: ' 3201021990****5678' ,
326374 passengerName: ' 张三' ,
327- footerInfo: ' 65773311920607K104567 北京南售'
375+ footerInfo: ' 65773311920607K104567 北京南售' ,
376+ discountType: ' student' , // 示例:学生票
377+ berthType: ' ' , // 铺位类型(上/中/下)
378+ berthNumber: ' ' , // 铺位号(数字部分)
379+ });
380+
381+ // 定义卧铺类型列表(用于判断是否显示铺位选择)
382+ const sleeperTypes = ref ([
383+ ' 软卧' , ' 硬卧' , ' 动卧' , ' 高级软卧' , ' 一等卧' , ' 二等卧'
384+ ]);
385+
386+ // 铺位类型选项
387+ const berthOptions = ref ([
388+ { label: ' 上铺' , value: ' 上' },
389+ { label: ' 中铺' , value: ' 中' },
390+ { label: ' 下铺' , value: ' 下' }
391+ ]);
392+
393+ // 监听座位类型变化,重置铺位信息
394+ watch (() => form .seatType , (newVal ) => {
395+ if (! sleeperTypes .value .includes (newVal)) {
396+ form .berthType = ' ' ;
397+ form .berthNumber = ' ' ;
398+ }
399+ });
400+
401+ // 计算最终座位号(铺位号+铺位类型)
402+ const finalSeatNumber = computed (() => {
403+ if (sleeperTypes .value .includes (form .seatType ) && form .berthNumber && form .berthType ) {
404+ return ` ${ form .berthNumber }${ form .berthType } ` ;
405+ }
406+ return form .seatNumber ;
328407});
329408
330409// 火车票组件ref
0 commit comments