This commit is contained in:
aihe 2024-07-19 18:23:50 +08:00
parent 370fd0b414
commit 0cfde79286
3 changed files with 20 additions and 23 deletions

View File

@ -154,19 +154,10 @@
} }
} }
}, },
async addEmptyItem(item) { async addEmptyItem() {
const list = await this.getListData({ this.submitVals.regIds.push(undefined)
regionType: this.curTabIndex + 1, this.submitVals.regNames.push('请选择')
parentId: item.code this.curTabIndex = this.curTabIndex + 1
})
// 选择最后一个tab视图 才做追加
if (list.length > 0 && this.curTabIndex + 1 == this.submitVals.regIds.length) {
this.submitVals.regIds.push(undefined)
this.submitVals.regNames.push('请选择')
}
if(list.length > 0) {
this.curTabIndex = this.curTabIndex + 1
}
}, },
async selectItemRegion(item = {}) { async selectItemRegion(item = {}) {
this.keywords = '' this.keywords = ''
@ -177,14 +168,22 @@
this.submitVals.regIds.push(item.code) this.submitVals.regIds.push(item.code)
this.submitVals.regNames.push(item.name) this.submitVals.regNames.push(item.name)
} }
// 选中后切换下一层级视图 const list = await this.getListData({
this.addEmptyItem(item) regionType: this.curTabIndex + 1,
parentId: item.code
})
// 选择最后一个tab视图 才做追加
if (list.length > 0 && this.curTabIndex + 1 == this.submitVals.regIds.length) {
this.addEmptyItem(item)
}
}, },
handleCloseModal() { handleCloseModal() {
this.$emit('update:show', false) this.$emit('update:show', false)
}, },
handleSubmitValue() { handleSubmitValue() {
const val = this.submitVals const val = this.submitVals
val.regIds = val.regIds.filter(t=> typeof(t) != 'undefined')
val.regNames = val.regNames.filter(t=> t != '请选择')
this.$emit('onSure', val) this.$emit('onSure', val)
this.$emit('update:value', val) this.$emit('update:value', val)
this.handleCloseModal() this.handleCloseModal()

View File

@ -156,9 +156,8 @@
Object.assign(this.submitParam, data) Object.assign(this.submitParam, data)
}, },
handleAddressChoose(data) { handleAddressChoose(data) {
data.regIds.map((regId, index)=> { addressNameCodeMap.map((nameCodeMap, index)=> {
let nameCodeMap = addressNameCodeMap[index] this.submitParam[nameCodeMap.codeKey] = data.regIds[index]
this.submitParam[nameCodeMap.codeKey] = regId
this.submitParam[nameCodeMap.nameKey] = data.regNames[index] this.submitParam[nameCodeMap.nameKey] = data.regNames[index]
}) })
}, },

View File

@ -5,7 +5,7 @@
<view class="pgb-header"> <view class="pgb-header">
<view class="com-jianju"> <view class="com-jianju">
<!-- 关键字搜索框 --> <!-- 关键字搜索框 -->
<tpx-search placeholder="选择地址" v-model:value="addressText" @click="showAddress"></tpx-search> <tpx-search placeholder="选择地址" :value="getAddressDetail(searchParam, false)" @click="showAddress"></tpx-search>
</view> </view>
</view> </view>
</template> </template>
@ -73,6 +73,7 @@
onUnload() { onUnload() {
}, },
methods: { methods: {
getAddressDetail,
getListFun: apiService.getSendSiteList, getListFun: apiService.getSendSiteList,
initData(){ initData(){
@ -85,11 +86,9 @@
this.addressModal.show = true this.addressModal.show = true
}, },
handleAddressChoose(data) { handleAddressChoose(data) {
data.regIds.map((regId, index)=> { addressNameCodeMap.map((nameCodeMap, index)=> {
let nameCodeMap = addressNameCodeMap[index] this.searchParam[nameCodeMap.codeKey] = data.regIds[index]
this.searchParam[nameCodeMap.codeKey] = regId
this.searchParam[nameCodeMap.nameKey] = data.regNames[index] this.searchParam[nameCodeMap.nameKey] = data.regNames[index]
this.addressText = getAddressDetail(this.searchParam)
}) })
}, },
} }