修复了点标签报错的问题

dev
RogerWork 4 months ago
parent 2987a25871
commit 7c2d423419
  1. 1
      src/components/ec_api/BasicConfig.vue
  2. 53
      src/components/ec_api/TabArea.vue
  3. 6
      src/store/index.js

@ -137,6 +137,7 @@ function handle_api_data() {
SelectApiId.value.forEach(api_id => {
if (ApiParams.value.hasOwnProperty(api_id)) {
SelectApiParams.value[api_id] = ApiParams.value[api_id]
SelectApiParams.value[api_id].forEach(item => item['is_preset'] = true)
}
})
}

@ -20,7 +20,7 @@ const ApiTableRef = ref(null) // 表格的Ref
// const multipleSelection = ref([]) // checkbox
//
const UserApiData = ref({api: {}, base_info: {}})
const UserApiData = ref({api: {}, base_info: {}, tab: {}})
//
//
@ -31,6 +31,7 @@ function handleParamsChange(newCheckedResult) {
}
function handleParamsSelect(val) {
console.log('val', val)
UserApiData.value.api[activeTab.value].params.forEach(param => {
@ -39,9 +40,8 @@ function handleParamsSelect(val) {
})
}
// function handleTabChange(){
// //
// markIsRequestSelection()
// function handleTabChange(val){
// console.log('handleTabChange', val)
// }
//
@ -53,7 +53,7 @@ function markIsChecked() {
console.log('item', item)
if (item['is_checked'] === true) {
console.log('ApiTableRef.value', ApiTableRef.value)
ApiTableRef.value[activeTab.value - 1].toggleRowSelection(item, true)
ApiTableRef.value[UserApiData.value.tab[activeTab.value]].toggleRowSelection(item, true)
}
})
// console.log(multipleSelection.value)
@ -67,8 +67,12 @@ function initApiData() {
cinema: store.state.ecApiModule.ec_api_data.cinema,
channel: store.state.ecApiModule.ec_api_data.channel,
}
let api_id_array = []
let api_tab = {}
if (store.state.ecApiModule.ec_api_data.api) {
store.state.ecApiModule.ec_api_data.api.forEach(item => {
store.state.ecApiModule.ec_api_data.api.forEach((item, index) => {
api_id_array.push(item.id)
api_tab[item.id] = index
if (!UserApiData.value['api'].hasOwnProperty(item.id)) {
UserApiData.value['api'][item.id] = {
'id': item.id,
@ -79,27 +83,28 @@ function initApiData() {
}
}
})
Object.values(UserApiData.value['api']).forEach((api) => {
if (api_id_array.indexOf(api['id']) < 0) {
delete UserApiData.value['api'][api['id']]
}
})
UserApiData.value.tab = api_tab
}
console.log('initApiData.UserApiData', UserApiData.value)
}
// ec_select_api
watch(() => store.state.ecApiModule.ec_api_data.api, (oldValue, newValue) => {
console.log('watch')
console.log('store.state.ecApiModule.ec_api_data.api', store.state.ecApiModule.ec_api_data.api)
console.log('newValue', newValue)
//
initApiData()
let tempId = 1
if (newValue.length > 0) {
tempId = newValue[0].id
//
const select_api_id = store.getters['ecApiModule/ec_select_api_getter']
if (select_api_id.indexOf(activeTab.value) < 0) {
activeTab.value = select_api_id[0]
}
newValue.forEach(item => {
if (item.id === activeTab.value) {
tempId = activeTab.value
}
})
activeTab.value = tempId
}, {deep: true})
@ -143,9 +148,15 @@ function addNewParams() {
param: '',
value: '',
is_request: false,
is_checked: false
is_checked: false,
is_preset: false
})
}
function test() {
console.log('store.state.ecApiModule.ec_api_data.api', store.state.ecApiModule.ec_api_data.api)
console.log('UserApiData.value', UserApiData.value)
}
</script>
<template>
@ -165,7 +176,7 @@ function addNewParams() {
<el-table-column type="selection" width="50"/>
<el-table-column label="字段名" width="120">
<template v-slot="scope">
<span v-if="scope.row.param">{{ scope.row.param }}</span>
<span v-if="scope.row.is_preset">{{ scope.row.param }}</span>
<span v-else><el-input type="text" placeholder="输入字段名" v-model="scope.row.param"></el-input></span>
</template>
</el-table-column>
@ -194,7 +205,7 @@ function addNewParams() {
<el-input type="text">1111</el-input>
</el-col>
<el-col :span="2">
<el-button type="primary">发送</el-button>
<el-button type="primary" @click="test">发送</el-button>
</el-col>
<el-col :span="8">
</el-col>

@ -47,7 +47,11 @@ const ecApiModule = {
return state.ec_api_data
},
ec_select_api_getter: state => {
return state.ec_api_data.api
let select_api_id = []
state.ec_api_data.api.forEach(item => {
select_api_id.push(item.id)
})
return select_api_id
},
},
mutations: {

Loading…
Cancel
Save