修复页面切换后回填参数的逻辑错误

dev
RogerWork 4 months ago
parent 97eb387f10
commit 1a2ba162cf
  1. 98
      src/components/ec_api/BasicConfig.vue

@ -19,21 +19,21 @@ const store = useStore()
// //
const Env = ref({}) const Env = ref({})
const EnvArray = [] const EnvArray = ref([])
const SelectEnv = ref('') const SelectEnv = ref('')
// //
const Cinema = ref({}) const Cinema = ref({})
let CinemaByEnv = [] let CinemaByEnv = ref([])
const SelectCinema = ref('') const SelectCinema = ref('')
// //
const ApiType = [{name: "非会员", value: "nonmember"}, {name: "会员", value: "member"}] const ApiType = ref([{name: "非会员", value: "nonmember"}, {name: "会员", value: "member"}])
const SelectType = ref('') const SelectType = ref('')
// //
const Channel = ref({}) const Channel = ref({})
let ChannelByType = [] let ChannelByType = ref([])
const SelectChannel = ref('') const SelectChannel = ref('')
// //
@ -53,14 +53,14 @@ const SelectApiParams = ref({})
// //
function env_on_change() { function env_on_change() {
// //
CinemaByEnv = [] CinemaByEnv.value = []
SelectCinema.value = '' SelectCinema.value = ''
SelectType.value = '' SelectType.value = ''
SelectChannel.value = '' SelectChannel.value = ''
// //
Cinema.value.forEach(data => { Cinema.value.forEach(data => {
if (data.env === SelectEnv.value) { if (data.env === SelectEnv.value) {
CinemaByEnv.push(data) CinemaByEnv.value.push(data)
} }
}) })
} }
@ -68,14 +68,14 @@ function env_on_change() {
// //
function type_on_change() { function type_on_change() {
// //
ChannelByType = [] ChannelByType.value = []
SelectChannel.value = '' SelectChannel.value = ''
SelectApiId.value = [] SelectApiId.value = []
SelectApiGroup.value = [] SelectApiGroup.value = []
// //
Channel.value.forEach(data => { Channel.value.forEach(data => {
if (data.type === SelectType.value && data.env === SelectEnv.value) { if (data.type === SelectType.value && data.env === SelectEnv.value) {
ChannelByType.push(data) ChannelByType.value.push(data)
} }
}) })
// //
@ -90,6 +90,32 @@ function basic_info_change() {
store_data() store_data()
} }
//
async function get_api_env() {
await get_ec_api_env().then(res => {
Env.value = res
Env.value.forEach(data => {
if (!EnvArray.value.some(item => item.name === data.name)) {
EnvArray.value.push({name: data.name, code: data.code})
}
})
});
}
//
async function get_api_cinema() {
get_ec_api_cinema().then(res => {
Cinema.value = res
})
}
//
async function get_api_channel() {
await get_ec_api_channel().then(res => {
Channel.value = res
})
}
// //
async function get_api_by_type(api_type) { async function get_api_by_type(api_type) {
await get_ec_api_api(api_type).then(res => { await get_ec_api_api(api_type).then(res => {
@ -153,37 +179,51 @@ function store_data() {
cinema: SelectCinema.value, cinema: SelectCinema.value,
channel: SelectChannel.value, channel: SelectChannel.value,
select_api_id: SelectApiId.value, select_api_id: SelectApiId.value,
type: SelectType.value,
api_group: SelectApiGroup.value,
cinema_env: CinemaByEnv.value,
channel_type: ChannelByType.value,
select_api: SelectApi.value,
api: SelectApi.value, api: SelectApi.value,
api_params: SelectApiParams.value api_params: SelectApiParams.value
}) })
console.log('select_data.value', select_data.value)
// store // store
store.commit('ecApiModule/add_ec_api_data', select_data.value) store.commit('ecApiModule/add_ec_api_data', select_data.value)
store.commit('ecApiModule/change_ec_select_api', SelectApi.value) store.commit('ecApiModule/change_ec_select_api', SelectApi.value)
console.log('store.state.ecApiModule.ec_api_data', store.state.ecApiModule.ec_api_data)
} }
//
function restore_data() {
SelectEnv.value = store.state.ecApiModule.ec_api_data.env
SelectCinema.value = store.state.ecApiModule.ec_api_data.cinema
SelectType.value = store.state.ecApiModule.ec_api_data.type
SelectChannel.value = store.state.ecApiModule.ec_api_data.channel
SelectApiGroup.value = store.state.ecApiModule.ec_api_data.api_group
SelectApiId.value = store.state.ecApiModule.ec_api_data.select_api_id
CinemaByEnv.value = store.state.ecApiModule.ec_api_data.cinema_env
ChannelByType.value = store.state.ecApiModule.ec_api_data.channel_type
SelectApi.value = store.state.ecApiModule.ec_api_data.select_api ? store.state.ecApiModule.ec_api_data.select_api : []
}
onMounted(() => { onMounted(() => {
console.log('onMounted BasicConfig')
SelectType.value = store.state.ecApiModule.ec_api_data.type
// //
get_ec_api_env().then(res => { get_api_env()
Env.value = res
Env.value.forEach(data => {
if (!EnvArray.some(item => item.name === data.name)) {
EnvArray.push({name: data.name, code: data.code})
}
})
});
// //
get_ec_api_cinema().then(res => { get_api_cinema()
Cinema.value = res
})
// //
get_ec_api_channel().then(res => { get_api_channel()
Channel.value = res //
}) get_api_group_by_type(SelectType.value)
//
get_api_by_type(SelectType.value)
//
get_api_params_by_type(SelectType.value)
//
restore_data()
console.log('BasicConfig onMounted store.state.ecApiModule.ec_api_data', store.state.ecApiModule.ec_api_data)
}) })
@ -207,7 +247,8 @@ onMounted(() => {
</el-col> </el-col>
<el-col :span="5"> <el-col :span="5">
<label class="name-label">影院</label> <label class="name-label">影院</label>
<el-select v-model="SelectCinema" placeholder="请选择" style="width: 160px" size="default" @change="basic_info_change"> <el-select v-model="SelectCinema" placeholder="请选择" style="width: 160px" size="default"
@change="basic_info_change">
<el-option <el-option
v-for="item in CinemaByEnv" v-for="item in CinemaByEnv"
:key="item.id" :key="item.id"
@ -232,7 +273,8 @@ onMounted(() => {
</el-col> </el-col>
<el-col :span="5"> <el-col :span="5">
<label class="name-label">渠道</label> <label class="name-label">渠道</label>
<el-select v-model="SelectChannel" placeholder="请选择" style="width: 160px" size="default" @change="basic_info_change"> <el-select v-model="SelectChannel" placeholder="请选择" style="width: 160px" size="default"
@change="basic_info_change">
<el-option <el-option
v-for="item in ChannelByType" v-for="item in ChannelByType"
:key="item.id" :key="item.id"

Loading…
Cancel
Save