From eaaa4286e58ab4e1fbaba28b90b592b19b4c3025 Mon Sep 17 00:00:00 2001 From: RogerWork Date: Fri, 19 Jul 2024 17:57:26 +0800 Subject: [PATCH] =?UTF-8?q?BasicConfig=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=B7=B2=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/ec_api.js | 9 ++ src/components/ec_api/BasicConfig.vue | 101 ++++++++++----- src/components/ec_api/TabArea.vue | 171 +++++++++++++++++++++++-- src/components/update/CinemaUpdate.vue | 44 +++---- src/components/update/Tips.vue | 6 +- src/request/config.js | 4 +- src/store/index.js | 70 +++++++++- src/views/ec_api/index.vue | 3 + src/views/update/index.vue | 2 +- 9 files changed, 330 insertions(+), 80 deletions(-) diff --git a/src/apis/ec_api.js b/src/apis/ec_api.js index f951588..48100eb 100644 --- a/src/apis/ec_api.js +++ b/src/apis/ec_api.js @@ -43,6 +43,15 @@ export const get_ec_api_api_params = (api_id) => { } }) } +export const get_ec_api_api_params_by_type = (api_type) => { + return request({ + url: 'ec/get_params_by_type', + method: 'get', + params: { + type: api_type + } + }) +} export const get_ec_api_api_group = (api_type) => { return request({ diff --git a/src/components/ec_api/BasicConfig.vue b/src/components/ec_api/BasicConfig.vue index 62f79aa..a007e4d 100644 --- a/src/components/ec_api/BasicConfig.vue +++ b/src/components/ec_api/BasicConfig.vue @@ -4,9 +4,11 @@ import { get_ec_api_cinema, get_ec_api_channel, get_ec_api_api, - get_ec_api_api_group, get_ec_api_api_params + get_ec_api_api_group, + get_ec_api_api_params, + get_ec_api_api_params_by_type } from "@/apis/ec_api.js"; -import {ref} from "vue"; +import {ref, reactive, toRefs} from "vue"; import {onMounted} from "vue"; import {useStore} from "vuex"; import {change_cinema_user} from "@/apis/update.js"; @@ -35,13 +37,19 @@ let ChannelByType = [] const SelectChannel = ref('') // 定义接口相关变量 -const Api = ref({}) -const SelectApi = ref([]) +const Api = ref([]) // 存储接口数据 +const SelectApiId = ref([]) // 存储选择的接口 +const SelectApi = ref([]) // 存储选择的接口 // 定义接口组相关变量 const ApiGroup = ref({}) const SelectApiGroup = ref([]) +// 定义接口参数 +const ApiParams = ref({}) +const SelectApiParams = ref({}) + + // 通过环境计算影院 function env_on_change() { // 初始化值 @@ -62,7 +70,7 @@ function type_on_change() { // 重置数据 ChannelByType = [] SelectChannel.value = '' - SelectApi.value = [] + SelectApiId.value = [] SelectApiGroup.value = [] // 计算渠道 Channel.value.forEach(data => { @@ -74,6 +82,8 @@ function type_on_change() { get_api_group_by_type(SelectType.value) // 获取接口数据 get_api_by_type(SelectType.value) + // 获取接口参数 + get_api_params_by_type(SelectType.value) } // 获取接口 @@ -90,49 +100,71 @@ async function get_api_group_by_type(api_type) { }) } +// 获取 接口参数 +async function get_api_params_by_type(api_type) { + await get_ec_api_api_params_by_type(api_type).then(res => { + ApiParams.value = res + }) +} + // OnChange相关 // 选择接口组后自动勾选接口 function api_group_on_change() { - SelectApi.value = JSON.parse(String(SelectApiGroup.value)) - get_api_params(SelectApi.value) + SelectApiId.value = JSON.parse(String(SelectApiGroup.value)) + handle_api_data() + store_data() + } // 修改了接口后,取消选择接口组 function api_on_change() { SelectApiGroup.value = [] - get_api_params(SelectApi.value) + handle_api_data() + store_data() +} + +function handle_api_data() { + // 生成被选择的api的数组 + SelectApiId.value.forEach(api_id => { + Api.value.forEach(api => { + if (api.id === api_id) { + SelectApi.value.push(api) + } + }) + }) + // 生成被选择的api参数对象 + SelectApiId.value.forEach(api_id => { + if (ApiParams.value.hasOwnProperty(api_id)) { + SelectApiParams.value[api_id] = ApiParams.value[api_id] + } + }) + + + console.log('Api.value', Api.value) + console.log('SelectApiId.value', SelectApiId.value) + console.log('SelectApi.value', SelectApi.value) + console.log('ApiParams.value', ApiParams.value) + console.log('SelectApiParams.value', SelectApiParams.value) } -function get_api_params(api_id_array) { - // 生成共享数据 +// 生成共享数据 +function store_data() { let select_data = ref({ env: SelectEnv.value, cinema: SelectCinema.value, channel: SelectChannel.value, - api: SelectApi.value - }) - // 处理接口,过滤调选择的接口 - let api_data = ref([]) - Api.value.forEach(api => { - if (SelectApi.value.indexOf(api.id) >= 0){ - api_data.value.push(api) - } + select_api_id: SelectApiId.value, + api: SelectApi.value, + api_params: SelectApiParams.value }) - store.state.ec_select_api = api_data.value - select_data.value["api_data"] = api_data.value - // 处理接口参数数据 - let api_params_data = ref([]) - api_id_array.forEach(api_id => { - get_ec_api_api_params(api_id).then(res => { - api_params_data.value.push({[api_id]: res}) - }) - }) - console.log('api_params_data', api_params_data.value) - select_data.value["api_params_data"] = api_params_data.value - console.log(select_data.value) - store.state.ec_api_data = select_data.value + console.log('select_data.value', select_data.value) + // 写入store + store.commit('ecApiModule/change_ec_select_api', SelectApiId.value) + store.commit('ecApiModule/add_ec_api_data', select_data.value) + console.log('store.state.ecApiModule.ec_api_data', store.state.ecApiModule.ec_api_data) } + onMounted(() => { // 获取环境 get_ec_api_env().then(res => { @@ -142,7 +174,6 @@ onMounted(() => { EnvArray.push({name: data.name, code: data.code}) } }) - console.log('Env_array', EnvArray) }); // 获取影院 @@ -154,9 +185,9 @@ onMounted(() => { get_ec_api_channel().then(res => { Channel.value = res }) - }) +