职工福利-福利选择:限制收获地址在哈尔滨指定的辖区(省市区下拉框隐藏哈尔滨市外的省份);

This commit is contained in:
dd3s_206
2026-06-02 19:58:15 +08:00
parent 4ce837abdf
commit 620a327c15
3 changed files with 140 additions and 39 deletions
@@ -34,13 +34,52 @@ layout("/mobile/platform.html"){
<script>
<!--#include("/mobile/welfare/include/areaList.js"){};include("/mobile/welfare/include/mixins.js"){}#-->
const welfareReceiveAreaList = {
province_list: {
230000: "黑龙江省"
},
city_list: {
230100: "哈尔滨市"
},
county_list: {
230102: "道里区",
230103: "南岗区",
230104: "道外区",
230108: "平房区",
230109: "松北区",
230110: "香坊区",
230111: "呼兰区",
230112: "阿城区",
230113: "双城区"
}
}
function getAreaCodeByName(source, name) {
const entry = Object.entries(source).find(([, label]) => label === name)
return entry ? entry[0] : null
}
function ensureAddressAreaList(sourceAreaList, addressInfo) {
const provinceCode = getAreaCodeByName(areaList.province_list, addressInfo.province)
const cityCode = getAreaCodeByName(areaList.city_list, addressInfo.city)
const countyCode = getAreaCodeByName(areaList.county_list, addressInfo.county)
if (!provinceCode || !cityCode || !countyCode) {
return sourceAreaList
}
const nextAreaList = JSON.parse(JSON.stringify(sourceAreaList))
nextAreaList.province_list[provinceCode] = addressInfo.province
nextAreaList.city_list[cityCode] = addressInfo.city
nextAreaList.county_list[countyCode] = addressInfo.county
return nextAreaList
}
const vue = new Vue({
el: "#app",
mixins: [mobileMixins, welfareMixins],
data() {
return {
projectId: GetQueryString("projectId"),
areaList: areaList,
areaList: welfareReceiveAreaList,
addressInfo: {},
addressId: null
}
@@ -95,6 +134,7 @@ layout("/mobile/platform.html"){
const resp = await $.get("/mobile/welfare/mine/findOneUserAddress", { id: this.addressId })
if (resp.code === 0) {
this.addressInfo = resp.data
this.areaList = ensureAddressAreaList(welfareReceiveAreaList, this.addressInfo)
}
this.closeLoading()
} else {
@@ -115,12 +115,62 @@ layout("/layouts/platform.html"){
</el-dialog>
</div>
<script>
const welfareReceiveAreaList = ["道里区", "南岗区", "道外区", "香坊区", "呼兰区", "松北区", "阿城区", "双城区", "平房区"]
function getWelfareReceiveDzOptions() {
const province = chengShiList.find((c) => c.label === "黑龙江省")
if (!province) {
return []
}
const city = province.children.find((c) => c.label === "哈尔滨市")
if (!city) {
return []
}
return [
{
...province,
children: [
{
...city,
children: city.children.filter((county) => welfareReceiveAreaList.includes(county.label))
}
]
}
]
}
function ensureAddressDzOption(options, row) {
const provinceTemplate = chengShiList.find((c) => c.label === row.province)
const cityTemplate = provinceTemplate?.children?.find((c) => c.label === row.city)
if (!provinceTemplate || !cityTemplate) {
return options
}
const nextOptions = JSON.parse(JSON.stringify(options))
let province = nextOptions.find((c) => c.label === row.province)
if (!province) {
province = {...provinceTemplate, children: []}
nextOptions.push(province)
}
let city = province.children.find((c) => c.label === row.city)
if (!city) {
city = {...cityTemplate, children: []}
province.children.push(city)
}
if (row.county) {
const countyTemplate = cityTemplate.children?.find((c) => c.label === row.county)
if (countyTemplate && !city.children.find((c) => c.label === row.county)) {
city.children.push(countyTemplate)
}
}
return nextOptions
}
const vue = new Vue({
el: "#app",
mixins: [initTableMixins],
data() {
return {
dzOptions: chengShiList,
dzOptions: getWelfareReceiveDzOptions(),
dialogVisible: false,
tableColumns: [
{ prop: "userName", label: "收货人" },
@@ -180,6 +230,7 @@ layout("/layouts/platform.html"){
}
},
openAddress() {
this.dzOptions = getWelfareReceiveDzOptions()
this.formData = {
userName: "${@shiro.getPrincipalProperty('username')}",
tel: "${@shiro.getPrincipalProperty('mobile')}"
@@ -223,16 +274,15 @@ layout("/layouts/platform.html"){
})
},
openEdit(row) {
this.dzOptions = ensureAddressDzOption(getWelfareReceiveDzOptions(), row)
row.addressList = []
const province = chengShiList.find((c) => c.label === row.province)
const province = this.dzOptions.find((c) => c.label === row.province)
row.addressList.push(province.value)
const city = province.children.find((p) => p.label === row.city)
row.addressList.push(city.value)
if (row.county) {
const county = city.children.find((p) => p.label === row.county)
if (county) {
row.addressList.push(county.value)
}
row.addressList.push(county.value)
}
this.formData = { ...row }
@@ -245,7 +245,7 @@ layout("/layouts/platform.html"){
:max="option.maxNum"
:min="0"
@keydown.native="onKeydown"
@change="numChange(option.selectNum, option, oidx)"
@change="(value, oldValue)=>{numChange(value, oldValue, option, oidx)}"
style="width: 150px; position: absolute; right: 0; bottom: 0"
v-model="option.selectNum"
></el-input-number>
@@ -257,6 +257,8 @@ layout("/layouts/platform.html"){
</div>
</div>
<!-- 取货门店改为非必填,PC端暂不展示门店选择入口 -->
<!--
<div style="margin-top: 17px">
<el-select
style="width: 100%"
@@ -274,6 +276,7 @@ layout("/layouts/platform.html"){
></el-option>
</el-select>
</div>
-->
</div>
</el-card>
</el-col>
@@ -447,6 +450,30 @@ layout("/layouts/platform.html"){
</el-dialog>
</div>
<script>
const welfareReceiveAreaList = ["道里区", "南岗区", "道外区", "香坊区", "呼兰区", "松北区", "阿城区", "双城区", "平房区"]
function getWelfareReceiveDzOptions() {
const province = chengShiList.find((c) => c.label === "黑龙江省")
if (!province) {
return []
}
const city = province.children.find((c) => c.label === "哈尔滨市")
if (!city) {
return []
}
return [
{
...province,
children: [
{
...city,
children: city.children.filter((county) => welfareReceiveAreaList.includes(county.label))
}
]
}
]
}
const vue = new Vue({
el: "#app",
mixins: [initTableMixins],
@@ -457,13 +484,13 @@ layout("/layouts/platform.html"){
welfareSignMode: [],
userSelection: [],
userSign: "",
dzOptions: chengShiList,
dzOptions: getWelfareReceiveDzOptions(),
addressList: [],
descData: "",
descDialogVisible: false,
selectedAddressCity: null,
selectedAddressCounty: null,
receiveAddressAreaList: ["道里区", "南岗区", "道外区", "香坊区", "呼兰区", "松北区", "阿城区", "双城区", "平房区"],
receiveAddressAreaList: welfareReceiveAreaList,
projectInfo: {},
welfareSubject: {},
@@ -601,7 +628,7 @@ layout("/layouts/platform.html"){
})
},
//数量更改
numChange(value, option, optionIndex) {
numChange(value, oldValue, option, optionIndex) {
const {
isIntegralMode,
isCheckBox,
@@ -612,7 +639,15 @@ layout("/layouts/platform.html"){
if (isIntegralMode) {
this.calcTotalIntegral()
} else {
if (isCheckBox === "checkBox") {
if (isCheckBox !== "checkBox") {
if (value > 0) {
this.projectInfo.welfareProjectSubjects[0].options.forEach((v, index) => {
if (index !== optionIndex) {
this.$set(v, "selectNum", 0)
}
})
}
} else {
//判断是否支持单个多选
if (!singleOptionSupportMultipleSelection && value > 1) {
this.$set(this.projectInfo.welfareProjectSubjects[0].options[optionIndex], "selectNum", 1)
@@ -625,7 +660,7 @@ layout("/layouts/platform.html"){
const sum = selectNums.reduce((accumulator, currentValue) => accumulator + currentValue, 0)
if (sum > multiSelectNum) {
this.$set(this.projectInfo.welfareProjectSubjects[0].options[optionIndex], "selectNum", value - 1)
this.$set(this.projectInfo.welfareProjectSubjects[0].options[optionIndex], "selectNum", oldValue == null ? 0 : oldValue)
this.$message.warning("此次福利最多只能选择" + multiSelectNum + "份")
}
}
@@ -677,9 +712,8 @@ layout("/layouts/platform.html"){
if (valid) {
const {isCheckBox, multiSelectNum, singleOptionSupportMultipleSelection} = this.projectInfo
if (isCheckBox === "checkBox") {
if (this.sumSelectNum < multiSelectNum) {
//用户没有选择完
this.$message.warning("一共可以选择" + multiSelectNum + "份,您目前只选择了" + this.sumSelectNum + "份,快去选择吧!")
if (this.sumSelectNum === 0) {
this.$message.warning("您还没有选择福利套餐,快去选择吧!")
return
}
} else {
@@ -690,30 +724,6 @@ layout("/layouts/platform.html"){
}
}
// 判断门店是否选择
console.log(this.projectInfo.welfareProjectSubjects[0])
const chooseOptions = this.projectInfo.welfareProjectSubjects[0].options
.filter((v) => v.selectNum > 0 && v.shoppingId)
.map((item) => {
return {
optionName: item.optionName,
receiveAddressList: item.receiveAddressList,
selectNum: item.selectNum,
receiveAddress: item.receiveAddress
}
})
let isReceiveAddress = true
for (const item of chooseOptions) {
if (!item.receiveAddress && item.receiveAddressList.length > 0) {
this.$message.warning(item.optionName + "还没有选择收货门店哦")
isReceiveAddress = false
break
}
}
if (!isReceiveAddress) {
return
}
if (this.projectInfo.provideMode == 3) {
if (this.formData.receiveAddress == null || this.formData.receiveAddress === "") {
this.$message.warning("请填写收货地址")
@@ -740,6 +750,7 @@ layout("/layouts/platform.html"){
receiveAddress: this.projectInfo.provideMode === 3 ? this.formData.receiveAddress : v.receiveAddress,
userSign: this.formData.sign,
selectNum: v.selectNum
// selectNum: Number(v.selectNum)
}
})
const {code, msg, data} = await $.post("/platform/welfare/userChoose/confirmSelect", {