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

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 EnvArray = []
const EnvArray = ref([])
const SelectEnv = ref('')
//
const Cinema = ref({})
let CinemaByEnv = []
let CinemaByEnv = 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 Channel = ref({})
let ChannelByType = []
let ChannelByType = ref([])
const SelectChannel = ref('')
//
@ -53,14 +53,14 @@ const SelectApiParams = ref({})
//
function env_on_change() {
//
CinemaByEnv = []
CinemaByEnv.value = []
SelectCinema.value = ''
SelectType.value = ''
SelectChannel.value = ''
//
Cinema.value.forEach(data => {
if (data.env === SelectEnv.value) {
CinemaByEnv.push(data)
CinemaByEnv.value.push(data)
}
})
}
@ -68,14 +68,14 @@ function env_on_change() {
//
function type_on_change() {
//
ChannelByType = []
ChannelByType.value = []
SelectChannel.value = ''
SelectApiId.value = []
SelectApiGroup.value = []
//
Channel.value.forEach(data => {
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()
}
//
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) {
await get_ec_api_api(api_type).then(res => {
@ -153,37 +179,51 @@ function store_data() {
cinema: SelectCinema.value,
channel: SelectChannel.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_params: SelectApiParams.value
})
console.log('select_data.value', select_data.value)
// store
store.commit('ecApiModule/add_ec_api_data', select_data.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(() => {
console.log('onMounted BasicConfig')
SelectType.value = store.state.ecApiModule.ec_api_data.type
//
get_ec_api_env().then(res => {
Env.value = res
Env.value.forEach(data => {
if (!EnvArray.some(item => item.name === data.name)) {
EnvArray.push({name: data.name, code: data.code})
}
})
});
get_api_env()
//
get_ec_api_cinema().then(res => {
Cinema.value = res
})
get_api_cinema()
//
get_ec_api_channel().then(res => {
Channel.value = res
})
get_api_channel()
//
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 :span="5">
<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
v-for="item in CinemaByEnv"
:key="item.id"
@ -232,7 +273,8 @@ onMounted(() => {
</el-col>
<el-col :span="5">
<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
v-for="item in ChannelByType"
:key="item.id"

Loading…
Cancel
Save