This commit is contained in:
aihe 2024-04-28 23:32:58 +08:00
parent b3c11a43a4
commit 647c1dd0fd

View File

@ -3,7 +3,6 @@
<view style="position: relative;height: calc(75vh);"> <view style="position: relative;height: calc(75vh);">
<tpx-layout> <tpx-layout>
<template v-slot:header> <template v-slot:header>
<view class="stp-list"> <view class="stp-list">
<view v-for="(item, index) in submitVals.regNames" <view v-for="(item, index) in submitVals.regNames"
:class="`stp-item ${curTabIndex == index?'active':''}`" @click="changeCurTab(index)"> :class="`stp-item ${curTabIndex == index?'active':''}`" @click="changeCurTab(index)">
@ -124,14 +123,14 @@
} }
}, },
async getListData({ async getListData({
parentId parentId, regionType
} = {}) { } = {}) {
let countryId = this.submitVals.regIds[0] // 最外层是国家id let countryId = this.submitVals.regIds[0] // 最外层是国家id
if (parentId == countryId) { if (parentId == countryId) {
parentId = undefined parentId = undefined
} }
const res = await apiService.getEmisRegion({ const res = await apiService.getEmisRegion({
regionType: this.curTabIndex + 1, // 必填 regionType, // 必填
parentCode: parentId, parentCode: parentId,
countryCode: countryId, countryCode: countryId,
}) })
@ -141,31 +140,38 @@
t.nameEn = t.regionNameEn t.nameEn = t.regionNameEn
t.code = t.code || t.regionCode t.code = t.code || t.regionCode
}) })
if (list.length > 0) { this.curList = list
this.curList = list
}
return list return list
}, },
changeCurTab(index) { changeCurTab(index) {
this.curTabIndex = index this.curTabIndex = index
if (index == 0) { if (index == 0) {
// 国家特殊处理
this.curList = this.curCountryList this.curList = this.curCountryList
} else { } else {
let parentId = this.submitVals.regIds[index] let parentId = this.submitVals.regIds[index-1]
this.getListData({ // 有父级code的才做刷新列表视图
parentId if(parentId) {
}) this.getListData({
regionType: this.curTabIndex,
parentId
})
}
} }
}, },
async addEmptyItem(item) { async addEmptyItem(item) {
const list = await this.getListData({ const list = await this.getListData({
regionType: this.curTabIndex + 1,
parentId: item.code parentId: item.code
}) })
if (list.length > 0) { // 选择最后一个tab视图 才做追加
this.curTabIndex = this.curTabIndex + 1 if (list.length > 0 && this.curTabIndex + 1 == this.submitVals.regIds.length) {
this.submitVals.regIds.push() this.submitVals.regIds.push(undefined)
this.submitVals.regNames.push('请选择') this.submitVals.regNames.push('请选择')
} }
if(list.length > 0) {
this.curTabIndex = this.curTabIndex + 1
}
}, },
async selectItemRegion(item = {}) { async selectItemRegion(item = {}) {
// 选择数据变化,需清除下所有层级选中数据 // 选择数据变化,需清除下所有层级选中数据