职工福利-福利选择:限制收获地址在哈尔滨指定的辖区(省市区下拉框隐藏哈尔滨市外的省份);
This commit is contained in:
@@ -34,13 +34,52 @@ layout("/mobile/platform.html"){
|
|||||||
<script>
|
<script>
|
||||||
<!--#include("/mobile/welfare/include/areaList.js"){};include("/mobile/welfare/include/mixins.js"){}#-->
|
<!--#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({
|
const vue = new Vue({
|
||||||
el: "#app",
|
el: "#app",
|
||||||
mixins: [mobileMixins, welfareMixins],
|
mixins: [mobileMixins, welfareMixins],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
projectId: GetQueryString("projectId"),
|
projectId: GetQueryString("projectId"),
|
||||||
areaList: areaList,
|
areaList: welfareReceiveAreaList,
|
||||||
addressInfo: {},
|
addressInfo: {},
|
||||||
addressId: null
|
addressId: null
|
||||||
}
|
}
|
||||||
@@ -95,6 +134,7 @@ layout("/mobile/platform.html"){
|
|||||||
const resp = await $.get("/mobile/welfare/mine/findOneUserAddress", { id: this.addressId })
|
const resp = await $.get("/mobile/welfare/mine/findOneUserAddress", { id: this.addressId })
|
||||||
if (resp.code === 0) {
|
if (resp.code === 0) {
|
||||||
this.addressInfo = resp.data
|
this.addressInfo = resp.data
|
||||||
|
this.areaList = ensureAddressAreaList(welfareReceiveAreaList, this.addressInfo)
|
||||||
}
|
}
|
||||||
this.closeLoading()
|
this.closeLoading()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -115,12 +115,62 @@ layout("/layouts/platform.html"){
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<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({
|
const vue = new Vue({
|
||||||
el: "#app",
|
el: "#app",
|
||||||
mixins: [initTableMixins],
|
mixins: [initTableMixins],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dzOptions: chengShiList,
|
dzOptions: getWelfareReceiveDzOptions(),
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
tableColumns: [
|
tableColumns: [
|
||||||
{ prop: "userName", label: "收货人" },
|
{ prop: "userName", label: "收货人" },
|
||||||
@@ -180,6 +230,7 @@ layout("/layouts/platform.html"){
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
openAddress() {
|
openAddress() {
|
||||||
|
this.dzOptions = getWelfareReceiveDzOptions()
|
||||||
this.formData = {
|
this.formData = {
|
||||||
userName: "${@shiro.getPrincipalProperty('username')}",
|
userName: "${@shiro.getPrincipalProperty('username')}",
|
||||||
tel: "${@shiro.getPrincipalProperty('mobile')}"
|
tel: "${@shiro.getPrincipalProperty('mobile')}"
|
||||||
@@ -223,16 +274,15 @@ layout("/layouts/platform.html"){
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
openEdit(row) {
|
openEdit(row) {
|
||||||
|
this.dzOptions = ensureAddressDzOption(getWelfareReceiveDzOptions(), row)
|
||||||
row.addressList = []
|
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)
|
row.addressList.push(province.value)
|
||||||
const city = province.children.find((p) => p.label === row.city)
|
const city = province.children.find((p) => p.label === row.city)
|
||||||
row.addressList.push(city.value)
|
row.addressList.push(city.value)
|
||||||
if (row.county) {
|
if (row.county) {
|
||||||
const county = city.children.find((p) => p.label === 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 }
|
this.formData = { ...row }
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ layout("/layouts/platform.html"){
|
|||||||
:max="option.maxNum"
|
:max="option.maxNum"
|
||||||
:min="0"
|
:min="0"
|
||||||
@keydown.native="onKeydown"
|
@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"
|
style="width: 150px; position: absolute; right: 0; bottom: 0"
|
||||||
v-model="option.selectNum"
|
v-model="option.selectNum"
|
||||||
></el-input-number>
|
></el-input-number>
|
||||||
@@ -257,6 +257,8 @@ layout("/layouts/platform.html"){
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 取货门店改为非必填,PC端暂不展示门店选择入口 -->
|
||||||
|
<!--
|
||||||
<div style="margin-top: 17px">
|
<div style="margin-top: 17px">
|
||||||
<el-select
|
<el-select
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@@ -274,6 +276,7 @@ layout("/layouts/platform.html"){
|
|||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -447,6 +450,30 @@ layout("/layouts/platform.html"){
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<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({
|
const vue = new Vue({
|
||||||
el: "#app",
|
el: "#app",
|
||||||
mixins: [initTableMixins],
|
mixins: [initTableMixins],
|
||||||
@@ -457,13 +484,13 @@ layout("/layouts/platform.html"){
|
|||||||
welfareSignMode: [],
|
welfareSignMode: [],
|
||||||
userSelection: [],
|
userSelection: [],
|
||||||
userSign: "",
|
userSign: "",
|
||||||
dzOptions: chengShiList,
|
dzOptions: getWelfareReceiveDzOptions(),
|
||||||
addressList: [],
|
addressList: [],
|
||||||
descData: "",
|
descData: "",
|
||||||
descDialogVisible: false,
|
descDialogVisible: false,
|
||||||
selectedAddressCity: null,
|
selectedAddressCity: null,
|
||||||
selectedAddressCounty: null,
|
selectedAddressCounty: null,
|
||||||
receiveAddressAreaList: ["道里区", "南岗区", "道外区", "香坊区", "呼兰区", "松北区", "阿城区", "双城区", "平房区"],
|
receiveAddressAreaList: welfareReceiveAreaList,
|
||||||
|
|
||||||
projectInfo: {},
|
projectInfo: {},
|
||||||
welfareSubject: {},
|
welfareSubject: {},
|
||||||
@@ -601,7 +628,7 @@ layout("/layouts/platform.html"){
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
//数量更改
|
//数量更改
|
||||||
numChange(value, option, optionIndex) {
|
numChange(value, oldValue, option, optionIndex) {
|
||||||
const {
|
const {
|
||||||
isIntegralMode,
|
isIntegralMode,
|
||||||
isCheckBox,
|
isCheckBox,
|
||||||
@@ -612,7 +639,15 @@ layout("/layouts/platform.html"){
|
|||||||
if (isIntegralMode) {
|
if (isIntegralMode) {
|
||||||
this.calcTotalIntegral()
|
this.calcTotalIntegral()
|
||||||
} else {
|
} 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) {
|
if (!singleOptionSupportMultipleSelection && value > 1) {
|
||||||
this.$set(this.projectInfo.welfareProjectSubjects[0].options[optionIndex], "selectNum", 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)
|
const sum = selectNums.reduce((accumulator, currentValue) => accumulator + currentValue, 0)
|
||||||
|
|
||||||
if (sum > multiSelectNum) {
|
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 + "份")
|
this.$message.warning("此次福利最多只能选择" + multiSelectNum + "份")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,9 +712,8 @@ layout("/layouts/platform.html"){
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
const {isCheckBox, multiSelectNum, singleOptionSupportMultipleSelection} = this.projectInfo
|
const {isCheckBox, multiSelectNum, singleOptionSupportMultipleSelection} = this.projectInfo
|
||||||
if (isCheckBox === "checkBox") {
|
if (isCheckBox === "checkBox") {
|
||||||
if (this.sumSelectNum < multiSelectNum) {
|
if (this.sumSelectNum === 0) {
|
||||||
//用户没有选择完
|
this.$message.warning("您还没有选择福利套餐,快去选择吧!")
|
||||||
this.$message.warning("一共可以选择" + multiSelectNum + "份,您目前只选择了" + this.sumSelectNum + "份,快去选择吧!")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} 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.projectInfo.provideMode == 3) {
|
||||||
if (this.formData.receiveAddress == null || this.formData.receiveAddress === "") {
|
if (this.formData.receiveAddress == null || this.formData.receiveAddress === "") {
|
||||||
this.$message.warning("请填写收货地址")
|
this.$message.warning("请填写收货地址")
|
||||||
@@ -740,6 +750,7 @@ layout("/layouts/platform.html"){
|
|||||||
receiveAddress: this.projectInfo.provideMode === 3 ? this.formData.receiveAddress : v.receiveAddress,
|
receiveAddress: this.projectInfo.provideMode === 3 ? this.formData.receiveAddress : v.receiveAddress,
|
||||||
userSign: this.formData.sign,
|
userSign: this.formData.sign,
|
||||||
selectNum: v.selectNum
|
selectNum: v.selectNum
|
||||||
|
// selectNum: Number(v.selectNum)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const {code, msg, data} = await $.post("/platform/welfare/userChoose/confirmSelect", {
|
const {code, msg, data} = await $.post("/platform/welfare/userChoose/confirmSelect", {
|
||||||
|
|||||||
Reference in New Issue
Block a user