由于问题描述较为复杂且涉及的代码较多,我将提供一个基于PHP和Vue的简单示例,展示如何使用Element UI创建一个电影票预订和选座系统的前端部分。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Movie Ticket Booking</title>
<!-- 引入Element UI样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
<el-row>
<el-col :span="12">
<h2>选择电影场次</h2>
<el-select v-model="selectedShowing" placeholder="请选择">
<el-option
v-for="showing in showings"
:key="showing.id"
:label="showing.time"
:value="showing.id">
</el-option>
</el-select>
</el-col>
</el-row>
<el-row>
<el-col :span="18">
<h2>选择座位</h2>
<el-table :data="seats" @row-click="handleRowClick">
<el-table-column prop="number" label="座位号"></el-table-column>
<el-table-column prop="status" label="状态">
<template slot-scope="scope">
<span :style="{ color: scope.row.status === 'available' ? 'green' : 'red' }">{{ scope.row.status }}</span>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<el-button type="primary" @click="confirmSeats">确认选择</el-button>
</el-col>
</el-row>
</div>
<!-- 引入Vue -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
<!-- 引入Element UI组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
// 初始化Vue实例
new Vue({
el: '#app',
data: {
selectedShowing: null,
showings: [ // 假定的场次数据
{ id: 1, time: '21:00' },
{ id: 2, time: '23:00' }
],
seats: [ // 假定的座位数据
{ number: '01', status: 'available' },
{ number: '02', status: 'unavailable' }
]
},
methods: {
handleRowClick(row, column, event