parent
3ad2bc10a3
commit
f31a304359
5 changed files with 220 additions and 18 deletions
After Width: | Height: | Size: 266 KiB |
@ -0,0 +1,137 @@ |
||||
<script setup> |
||||
import {defineProps, ref, reactive, computed, watch, onMounted, onBeforeMount} from 'vue' |
||||
import {ec_api_set_user_data, ec_api_clear_user_data} from '@/apis/ec_api.js' |
||||
import {ElMessage} from "element-plus"; |
||||
|
||||
// 接收TabArea组件传递的参数 |
||||
const props = defineProps(['show', 'data']) |
||||
|
||||
// 定义用户选择的场次变量 |
||||
const selectShow = ref('') |
||||
const showList = reactive([]) |
||||
|
||||
// 处理用户选择的数据 |
||||
async function handle_set_user_data() { |
||||
let selectShowData = {} |
||||
props.show.forEach((item)=> { |
||||
if (item['id'] === selectShow.value) { |
||||
selectShowData = item |
||||
} |
||||
}) |
||||
const req_data = { |
||||
api: props.data.path, |
||||
member_type: props.data.type, |
||||
format: props.data.format, |
||||
user_data: JSON.stringify(selectShowData) |
||||
} |
||||
console.log('handle_set_user_data', req_data) |
||||
await ec_api_set_user_data(req_data).then( |
||||
(req) => { |
||||
if (req['result'] === 'success') { |
||||
ElMessage({message: '选择的场次已做为后续测试数据!', type: 'success'}) |
||||
} else { |
||||
ElMessage({message: '设置用户选择场次数据失败!', type: 'error'}) |
||||
} |
||||
} |
||||
).catch( |
||||
(err) => { |
||||
console.log(err) |
||||
ElMessage({message: '设置用户选择场次数据失败!', type: 'error'}) |
||||
} |
||||
) |
||||
} |
||||
|
||||
async function handle_clear_user_data() { |
||||
const req_data = { |
||||
api: props.data.path, |
||||
member_type: props.data.type, |
||||
} |
||||
console.log('handle_clear_user_data', req_data) |
||||
await ec_api_clear_user_data(req_data).then( |
||||
(req) => { |
||||
if (req['result'] === 'success') { |
||||
ElMessage({message: '选择的场次已清除,推荐参数将使用随机值!', type: 'success'}) |
||||
} else { |
||||
ElMessage({message: '清除用户选择场次数据失败!', type: 'error'}) |
||||
} |
||||
} |
||||
).catch( |
||||
(err) => { |
||||
console.log(err) |
||||
ElMessage({message: '清除用户选择场次数据失败!', type: 'error'}) |
||||
} |
||||
) |
||||
} |
||||
|
||||
onBeforeMount(() => { |
||||
// 挂载时生成用于展示的数据源 |
||||
props.show.forEach((item) => { |
||||
showList.push({ |
||||
key: item.id, |
||||
start: item['startTime'], |
||||
name: item['movieInfo'][0]['movieName'], |
||||
hall: item['hallName'], |
||||
data: item |
||||
}) |
||||
}) |
||||
}) |
||||
|
||||
|
||||
watch(() => selectShow.value, () => { |
||||
console.log('selectShow.value', selectShow.value) |
||||
handle_set_user_data() |
||||
}) |
||||
|
||||
</script> |
||||
|
||||
<template> |
||||
<hr id="break_line"/> |
||||
<div style="font-size: 16px; font-weight: bold; color: #909399; text-align: left; margin-bottom: 10px">选择场次: |
||||
<el-tooltip |
||||
class="box-item" |
||||
effect="dark" |
||||
content="点击清除选择后会将后台服务器中记录的选择内容清空,其他接口将通过随机获取的方式从此接口返回的数据中模拟参数" |
||||
placement="right" |
||||
> |
||||
<el-button size="small" style="font-weight: bold;color: #909399" @click="handle_clear_user_data">清除选择</el-button> |
||||
</el-tooltip> |
||||
</div> |
||||
<el-form style="max-width: 600px; margin-left: 20px"> |
||||
<el-form-item> |
||||
<el-radio-group v-model="selectShow"> |
||||
<el-radio-button v-for="s in showList" :label="s.key" :value="s.key" :key="s.key"> |
||||
<div style="text-align: left"> |
||||
<span>{{ s.key }}</span> -- <span style="font-weight: bold">{{ s.name }}</span><br> |
||||
<span>{{ s.start }}</span><br><span>{{ s.hall }}</span> |
||||
</div> |
||||
</el-radio-button> |
||||
</el-radio-group> |
||||
</el-form-item> |
||||
</el-form> |
||||
</template> |
||||
|
||||
<style scoped> |
||||
#break_line { |
||||
margin-top: 30px; |
||||
margin-bottom: 30px; |
||||
background-color: rgba(144, 147, 153, 0.5); |
||||
height: 1px; |
||||
border: none |
||||
} |
||||
|
||||
:deep(.el-radio-button) { |
||||
margin-bottom: 10px; |
||||
margin-right: 15px; |
||||
|
||||
} |
||||
|
||||
:deep(.el-radio-button__inner) { |
||||
width: 400px; |
||||
height: 60px; |
||||
background: #ebebeb; |
||||
color: #333; |
||||
border: 0 !important; |
||||
border-radius: 10px !important; |
||||
} |
||||
|
||||
</style> |
Loading…
Reference in new issue