提交 797b61ea 作者: 吴佳伟

fix: 地区字典改成本地存储,修复部分页面样式

上级 d86c6e60
...@@ -4,7 +4,7 @@ import { otherHttp } from '/@/utils/http/axios' ...@@ -4,7 +4,7 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api { enum Api {
purchaseList = '/purchaseSell/bizPurchase/list', // 采购需求列表 purchaseList = '/purchaseSell/bizPurchase/list', // 采购需求列表
supplyList = '/purchaseSell/bizSupply/list', // 供应需求列表 supplyList = '/purchaseSell/bizSupply/list', // 供应需求列表
purchaseSellDetails = '/purchaseSell/bizPurchase/queryByld', // 产销详情 purchaseSellDetails = '/purchaseSell/bizPurchase/queryById', // 产销详情
purchaseSell = '/purchaseSell/bizPurchase/add', // 发布采购需求 purchaseSell = '/purchaseSell/bizPurchase/add', // 发布采购需求
supplyAdd = '/purchaseSell/bizSupply/add', // 发布供应需求 supplyAdd = '/purchaseSell/bizSupply/add', // 发布供应需求
bizPurchaseSupplyRecord = '/purchaseSell/bizPurchaseSupplyRecord/add', // 报价 bizPurchaseSupplyRecord = '/purchaseSell/bizPurchaseSupplyRecord/add', // 报价
......
// 上传请求
import { otherHttp } from '/@/utils/http/axios'
enum Api {
cascaderHn = '/region/cascader/hn', // 获取湖南省内 市/区县/乡镇级联数据
}
/**
* 查询湖南省 市/区县/乡镇
* @returns 市/区县/乡镇
*/
export function cascaderHn() {
return otherHttp.get({
url: Api.cascaderHn,
})
}
\ No newline at end of file
...@@ -8,7 +8,6 @@ enum Api { ...@@ -8,7 +8,6 @@ enum Api {
farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务 farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务
farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务 farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务
farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务 farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务
cascaderHn = '/region/cascader/hn',
} }
/** /**
...@@ -80,14 +79,4 @@ export function farmMachineRegister(params = {}) { ...@@ -80,14 +79,4 @@ export function farmMachineRegister(params = {}) {
url: Api.farmMachineRegister, url: Api.farmMachineRegister,
params, params,
}) })
}
/**
* 查询湖南省 市/区县/乡镇
* @returns 市/区县/乡镇
*/
export function cascaderHn() {
return otherHttp.get({
url: Api.cascaderHn,
})
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import PriceDialog from './components/price-dialog.vue' import PriceDialog from './components/price-dialog.vue'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import { getText } from '@/utils/dict/area'
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
...@@ -92,7 +93,7 @@ ...@@ -92,7 +93,7 @@
pageData.purchaseDemands = [...pageData.purchaseDemands, ...records] pageData.purchaseDemands = [...pageData.purchaseDemands, ...records]
pageData.purchaseDemands = pageData.purchaseDemands.map((item) => ({ pageData.purchaseDemands = pageData.purchaseDemands.map((item) => ({
...item, ...item,
location: `${item.province}${item.city}`, location: getText(`${item.province},${item.city},${item.country}`),
})) }))
pageData.total = total pageData.total = total
}) })
...@@ -109,7 +110,7 @@ ...@@ -109,7 +110,7 @@
pageData.supplyInfos = [...pageData.supplyInfos, ...records] pageData.supplyInfos = [...pageData.supplyInfos, ...records]
pageData.supplyInfos = pageData.supplyInfos.map((item) => ({ pageData.supplyInfos = pageData.supplyInfos.map((item) => ({
...item, ...item,
location: `${item.province}${item.city}`, location: getText(`${item.province},${item.city},${item.country}`),
})) }))
pageData.total = total pageData.total = total
}) })
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData' import { areaOptions, getText } from '@/utils/dict/area'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
text: item.text, text: item.text,
} }
}) })
pageData.options.address = areaTree pageData.options.address = areaOptions
} }
function getCurrentAddressInfo() { function getCurrentAddressInfo() {
...@@ -138,7 +138,7 @@ return ...@@ -138,7 +138,7 @@ return
function getDetails(id) { function getDetails(id) {
ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => { ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => {
pageData.form = res pageData.form = res
pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}` pageData.form.address = `${res.province},${res.city},${res.country}`
pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify)?.text pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify)?.text
pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image) pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image)
}) })
...@@ -170,7 +170,7 @@ return ...@@ -170,7 +170,7 @@ return
pageData.show.classify = false pageData.show.classify = false
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.form.address = e.text.join('/') pageData.form.address = e.value.join(',')
pageData.show.address = false pageData.show.address = false
} }
...@@ -239,9 +239,9 @@ return ...@@ -239,9 +239,9 @@ return
function changeAddressValue(formData) { function changeAddressValue(formData) {
const addressValue = formData.address.split('/') const addressValue = formData.address.split('/')
if (addressValue.length === 3) { if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0]) formData.province = addressValue[0]
formData.city = getCodeByText(addressValue[1]) formData.city = addressValue[1]
formData.country = getCodeByText(addressValue[2]) formData.country = addressValue[2]
} }
} }
</script> </script>
...@@ -314,7 +314,7 @@ return ...@@ -314,7 +314,7 @@ return
<text class="label">省/市/区县</text> <text class="label">省/市/区县</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !form.address }"> <text class="select-text" :class="{ placeholder: !form.address }">
{{ form.address || '请选择省/市/区县' }} {{ getText(form.address) || '请选择省/市/区县' }}
</text> </text>
</view> </view>
</view> </view>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData' import { areaOptions, getText } from '@/utils/dict/area'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -124,8 +124,7 @@ ...@@ -124,8 +124,7 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
pageData.options.address = areaTree pageData.options.address = areaOptions
console.log(dictStore.getDictList.purchase_status)
pageData.options.status = dictStore.getDictList.purchase_status.map((item) => { pageData.options.status = dictStore.getDictList.purchase_status.map((item) => {
return { return {
...@@ -159,7 +158,7 @@ ...@@ -159,7 +158,7 @@
function getDetails(id) { function getDetails(id) {
ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => { ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => {
pageData.form = res pageData.form = res
pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}` pageData.form.address = `${res.province}/${res.city}/${res.country}`
pageData.form.statusText = pageData.options.status.find((item) => item.value == res.status).text pageData.form.statusText = pageData.options.status.find((item) => item.value == res.status).text
pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify).text pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify).text
pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image) pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image)
...@@ -196,7 +195,7 @@ ...@@ -196,7 +195,7 @@
pageData.show.classify = false pageData.show.classify = false
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.form.address = e.text.join('/') pageData.form.address = e.value.join(',')
pageData.show.address = false pageData.show.address = false
} }
function handleChangeStatus(e) { function handleChangeStatus(e) {
...@@ -268,11 +267,11 @@ ...@@ -268,11 +267,11 @@
* @param formData 表单数据 * @param formData 表单数据
*/ */
function changeAddressValue(formData) { function changeAddressValue(formData) {
const addressValue = formData.address.split('/') const addressValue = formData.address.split(',')
if (addressValue.length === 3) { if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0]) formData.province = addressValue[0]
formData.city = getCodeByText(addressValue[1]) formData.city = addressValue[1]
formData.country = getCodeByText(addressValue[2]) formData.country = addressValue[2]
} }
} }
</script> </script>
...@@ -366,7 +365,7 @@ ...@@ -366,7 +365,7 @@
<text class="label">省/市/区县</text> <text class="label">省/市/区县</text>
<view class="select-input" @click="show.address = true"> <view class="select-input" @click="show.address = true">
<text class="time-text" :class="{ placeholder: !form.address }"> <text class="time-text" :class="{ placeholder: !form.address }">
{{ form.address || '请选择省/市/区县' }} {{ getText(form.address) || '请选择省/市/区县' }}
</text> </text>
</view> </view>
</view> </view>
...@@ -385,13 +384,13 @@ ...@@ -385,13 +384,13 @@
<view class="time-range"> <view class="time-range">
<view class="time-input" @click="show.time1 = true"> <view class="time-input" @click="show.time1 = true">
<text class="time-text" :class="{ placeholder: !form.supplyStartDate }"> <text class="time-text" :class="{ placeholder: !form.supplyStartDate }">
{{ form.supplyStartDate || '供应开始时间' }} {{ form.supplyStartDate || '开始时间' }}
</text> </text>
</view> </view>
<text class="time-separator">-</text> <text class="time-separator">-</text>
<view class="time-input" @click="show.time2 = true"> <view class="time-input" @click="show.time2 = true">
<text class="time-text" :class="{ placeholder: !form.supplyEndDate }"> <text class="time-text" :class="{ placeholder: !form.supplyEndDate }">
{{ form.supplyEndDate || '供应结束时间' }} {{ form.supplyEndDate || '结束时间' }}
</text> </text>
</view> </view>
</view> </view>
...@@ -492,6 +491,7 @@ ...@@ -492,6 +491,7 @@
background-color: #e6f5e8; background-color: #e6f5e8;
width: 750rpx; width: 750rpx;
overflow-x: hidden; overflow-x: hidden;
.mt20 { .mt20 {
margin-top: 30rpx; margin-top: 30rpx;
background: #fff; background: #fff;
...@@ -504,7 +504,7 @@ ...@@ -504,7 +504,7 @@
margin: 30rpx auto; margin: 30rpx auto;
} }
.supply-form { .purchase-form {
background: transparent; background: transparent;
} }
...@@ -534,193 +534,194 @@ ...@@ -534,193 +534,194 @@
// 添加点击区域样式 // 添加点击区域样式
.select-input { .select-input {
position: relative; position: relative;
}
}
.form-row { .form-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.half-width { .half-width {
width: 48%; width: 48%;
} }
.align-center { .align-center {
align-items: center; align-items: center;
} }
.label { .label {
display: block; display: block;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
font-weight: 500; font-weight: 500;
width: 180rpx; width: 180rpx;
// margin-right: 20rpx; // margin-right: 20rpx;
} }
.input { .input {
width: 100%; width: 100%;
height: 80rpx; height: 80rpx;
background: #f8f9fa; background: #f8f9fa;
border-radius: 8rpx; border-radius: 8rpx;
padding: 0 20rpx; padding: 0 20rpx;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
&::placeholder { &::placeholder {
color: #999999; color: #999999;
} }
} }
.price-range { .price-range {
display: flex; display: flex;
align-items: center; align-items: center;
// justify-content: space-between; // justify-content: space-between;
} }
.price-input { .price-input {
width: 15%; width: 15%;
// height: 80rpx; // height: 80rpx;
// background: #f8f9fa; // background: #f8f9fa;
// border-radius: 8rpx; // border-radius: 8rpx;
padding: 0 10rpx; padding: 0 10rpx;
font-size: 28rpx; font-size: 28rpx;
text-align: center; text-align: center;
} }
.price-separator { .price-separator {
color: #666666; color: #666666;
font-size: 28rpx; font-size: 28rpx;
margin: 0 10rpx; margin: 0 10rpx;
} }
.select-input { .select-input {
flex: 1; flex: 1;
border-radius: 8rpx; border-radius: 8rpx;
padding: 0 20rpx; padding: 0 20rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
cursor: pointer; cursor: pointer;
} }
.select-text { .select-text {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
padding: 0 20rpx; padding: 0 20rpx;
&.placeholder { &.placeholder {
color: #999999; color: #999999;
} }
} }
.select-arrow { .select-arrow {
color: #999999; color: #999999;
font-size: 24rpx; font-size: 24rpx;
line-height: 1; line-height: 1;
} }
.time-range { .time-range {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.time-input { .time-input {
width: 45%; width: 45%;
// height: 80rpx; // height: 80rpx;
// background: #f8f9fa; // background: #f8f9fa;
border-radius: 8rpx; border-radius: 8rpx;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.time-text { .time-text {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
&.placeholder { &.placeholder {
color: #999999; color: #999999;
} }
} }
.time-separator { .time-separator {
color: #666666; color: #666666;
font-size: 28rpx; font-size: 28rpx;
margin: 0 10rpx; margin: 0 10rpx;
} }
.upload-area { .upload-area {
margin-top: 10rpx; margin-top: 10rpx;
} }
.custom-uploader { .custom-uploader {
:deep(.uni-file-picker__container) { :deep(.uni-file-picker__container) {
border: 2rpx dashed #d9d9d9; border: 2rpx dashed #d9d9d9;
border-radius: 8rpx; border-radius: 8rpx;
background: #f8f9fa; background: #f8f9fa;
} }
} }
.upload-placeholder { .upload-placeholder {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 200rpx; height: 200rpx;
color: #999999; color: #999999;
} }
.upload-icon { .upload-icon {
font-size: 48rpx; font-size: 48rpx;
margin-bottom: 10rpx; margin-bottom: 10rpx;
} }
.upload-text { .upload-text {
font-size: 24rpx; font-size: 24rpx;
} }
.submit-section { .submit-section {
background: transparent; background: transparent;
padding: 40rpx 0; padding: 40rpx 0;
} }
.submit-btn { .submit-btn {
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
background: #5db66f; background: #5db66f;
border-radius: 44rpx; border-radius: 44rpx;
color: #ffffff; color: #ffffff;
font-size: 32rpx; font-size: 32rpx;
font-weight: 500; font-weight: 500;
border: none; border: none;
&:active { &:active {
background: #4ca85c; background: #4ca85c;
opacity: 0.9; opacity: 0.9;
}
}
}
::v-deep .uni-input-placeholder {
font-size: 28rpx !important;
color: #999999 !important;
} }
}
}
:deep(.fui-button) { ::v-deep .uni-input-placeholder {
width: 690rpx; font-size: 28rpx !important;
border-color: #5db66f !important; color: #999999 !important;
background: #5db66f !important; }
}
// 移除fui-form的默认样式 :deep(.fui-button) {
:deep(.fui-form) { width: 690rpx;
background: transparent; border-color: #5db66f !important;
} background: #5db66f !important;
}
:deep(.fui-form__item) { // 移除fui-form的默认样式
background: transparent; :deep(.fui-form) {
border: none; background: transparent;
margin-bottom: 0; }
padding: 0;
} :deep(.fui-form__item) {
} background: transparent;
border: none;
margin-bottom: 0;
padding: 0;
} }
</style> </style>
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { areaOptions, getText } from '@/utils/dict/area'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
...@@ -92,41 +93,7 @@ ...@@ -92,41 +93,7 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
nongjifuwu.cascaderHn().then((res) => { pageData.options.address = areaOptions
pageData.options.address = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
}
function getScope(scope: any) {
if (!scope || !pageData.options.address) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options.address, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
} }
function getDetails(id) { function getDetails(id) {
...@@ -248,7 +215,7 @@ ...@@ -248,7 +215,7 @@
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !pageData.form.scope }"> <text class="select-text" :class="{ placeholder: !pageData.form.scope }">
{{ getScope(pageData.form.scope) || '请选择市/区县/乡镇' }} {{ getText(pageData.form.scope) || '请选择市/区县/乡镇' }}
</text> </text>
</view> </view>
</view> </view>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { areaOptions, getText } from '@/utils/dict/area'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
...@@ -79,41 +80,7 @@ ...@@ -79,41 +80,7 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
nongjifuwu.cascaderHn().then((res) => { pageData.options.address = areaOptions
pageData.options.address = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
}
function getScope(scope: any) {
if (!scope || !pageData.options.address) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options.address, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
} }
function getDetails(id) { function getDetails(id) {
...@@ -235,7 +202,7 @@ ...@@ -235,7 +202,7 @@
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
<text class="select-text" :class="{ placeholder: !pageData.form.scope }"> <text class="select-text" :class="{ placeholder: !pageData.form.scope }">
{{ getScope(pageData.form.scope) || '请选择市/区县/乡镇' }} {{ getText(pageData.form.scope) || '请选择市/区县/乡镇' }}
</text> </text>
</view> </view>
</view> </view>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { s } from 'vite/dist/node/types.d-aGj9QkWt' import { s } from 'vite/dist/node/types.d-aGj9QkWt'
import { areaOptions, getText } from '@/utils/dict/area'
onLoad((option) => { onLoad((option) => {
pageData.search.serviceType = Number(option.type) || 1 pageData.search.serviceType = Number(option.type) || 1
...@@ -68,9 +69,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -68,9 +69,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
} }
function getCascader() { function getCascader() {
NongjifuwuAPI.cascaderHn().then((res) => { pageData.options = areaOptions
pageData.options = JSON.parse(JSON.stringify(res[0].children).replaceAll('label', 'text'))
})
} }
// 分类标签点击事件 // 分类标签点击事件
...@@ -106,37 +105,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -106,37 +105,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
applyDialogRef.value.open(item) applyDialogRef.value.open(item)
} }
function getScope(scope: any) {
if (!scope || !pageData.options || pageData.options.length === 0) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(pageData.options, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
}
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.search.scope = e.value.join(',') pageData.search.scope = e.value.join(',')
...@@ -165,7 +134,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -165,7 +134,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
<view class="codefun-flex-row codefun-justify-between section_2"> <view class="codefun-flex-row codefun-justify-between section_2">
<text class="font_2 text_2">服务区域</text> <text class="font_2 text_2">服务区域</text>
<view class="codefun-flex-row codefun-items-center" @click="pageData.show.address = true"> <view class="codefun-flex-row codefun-items-center" @click="pageData.show.address = true">
<text class="font_2 text_3">{{ getScope(pageData.search.scope) || '选择区域' }}</text> <text class="font_2 text_3">{{ getText(pageData.search.scope) || '选择区域' }}</text>
<image <image
class="codefun-shrink-0 image_7 codefun-ml-4" class="codefun-shrink-0 image_7 codefun-ml-4"
src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png" src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png"
...@@ -206,7 +175,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt' ...@@ -206,7 +175,7 @@ import { s } from 'vite/dist/node/types.d-aGj9QkWt'
> >
<text class="font text_6">{{ item.name }}</text> <text class="font text_6">{{ item.name }}</text>
<text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0" <text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0"
>服务范围:{{ getScope(item.scope) }}</text >服务范围:{{ getText(item.scope) }}</text
> >
</view> </view>
<view class="flex justify-between" style="width: 100%"> <view class="flex justify-between" style="width: 100%">
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import * as UserAPI from '@/api/model/userInfo' import * as UserAPI from '@/api/model/userInfo'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import * as AreaDict from '@/utils/dict/area'
const dictStore = useDictStore() const dictStore = useDictStore()
const model = reactive({ const model = reactive({
...@@ -127,6 +128,7 @@ ...@@ -127,6 +128,7 @@
// 获取字典列表 // 获取字典列表
dictStore.setDictList() dictStore.setDictList()
AreaDict.refreshDictData()
// 查询金刚区数据 // 查询金刚区数据
getServiceItems() getServiceItems()
......
import { cascaderHn } from '/@/api/model/dict'
const storageKey = 'app_dict_data_area_cascaderHn';
export const getDictData = () => {
// 先从本地加载数据
let dictData = getLocalDict();
if (!dictData) {
// 如果本地没有数据,则从接口获取
cascaderHn().then(res => uni.setStorageSync(storageKey, JSON.stringify(res[0].children).replaceAll('label', 'text')));
}
return dictData;
}
/**
* 获取本地数据
*/
export const getLocalDict = () => {
const data = uni.getStorageSync(storageKey);
if (data) {
return data ? JSON.parse(data) : null;
}
return null;
}
/**
* 刷新数据
*/
export const refreshDictData = () => {
// 删除本地数据
uni.removeStorageSync(storageKey);
// 重新获取数据
getDictData();
}
export const areaOptions = getDictData();
export const getText = (scope: String) => {
if (!scope || !areaOptions || areaOptions.length === 0) {
return ''
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.text
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const text = findLabel(areaOptions, value.trim())
labels.push(text)
}
return labels ? labels.join(' / ') : ''
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论