Commit f0175120 by 匡雅琴

新增省市

1 parent 99f40552
<template>
<div>
<el-form ref="provinceForm" :model="provinceForm" label-width="80px" inline="true" class="province">
<el-select v-model="provinceForm.province" placeholder="选择省份" @change="selectProvince">
<el-select v-model="provinceForm.provinceName" placeholder="选择省份" @change="selectProvince">
<el-option v-for="item in AllData" :key="item.provinceId" :label="item.provinceName" :value="item.provinceName" @click.native="selectProvince(item)"></el-option>
</el-select>
<el-select v-model="provinceForm.city" placeholder="选择您所在的市" style="width:250px" @change="selectCity">
<el-select v-model="provinceForm.cityName" placeholder="选择您所在的市" style="width:250px" @change="selectCity">
<el-option v-for="item in cityList" :key="item.cityId" :label="item.cityName" :value="item.cityName" @click.native="selectCity(item)"></el-option>
</el-select>
</el-form>
......@@ -22,26 +22,32 @@ export default {
AllData: [],
cityList: [{ cityId: '', cityName: '请先选择省' }],
provinceForm: {
province: '', // 省值
city: '' // 市值
provinceName: '', // 省值
cityName: '', // 市值
provinceId: '',
cityId: ''
}
}
},
mounted() {
// 初始化
this.getProvinceList()
console.log(this.provinceName)
},
methods: {
init(provinceName, cityName) {
this.provinceForm = {
province: provinceName,
city: cityName
provinceName: provinceName,
cityName: cityName
}
console.log(this.AllData)
this.AllData.map(item => {
if (provinceName == item.provinceName) {
this.cityList = item.cityInfoList
this.provinceForm.provinceId = item.provinceId
this.cityList.map(itm => {
if (cityName == itm.cityName) {
this.provinceForm.cityId = itm.cityId
}
})
}
})
},
......@@ -54,7 +60,7 @@ export default {
// 选择省
selectProvince(val) {
console.log(val)
this.provinceForm.city = ''
this.provinceForm.cityName = ''
this.cityList = val.cityInfoList
this.$emit('getProvince', val.provinceName, val.provinceId)
},
......
......@@ -47,6 +47,7 @@
<el-row>
<el-col :span="24">
<el-form-item size="small" label="商户地址" class="form-row">
<!-- 省市 -->
<ProvinceCity ref="provinceForm" @getProvince="getProvince" @getCity="getCity"></ProvinceCity>
<el-input readonly v-model="accountAddForm.merchantAddress"></el-input>
<el-button type="primary" class="form-btn" @click="hanleSelectMap">选择地址</el-button>
......@@ -277,30 +278,34 @@ export default {
var province = address.slice(0, provinceIdx)
var city = address.slice(provinceIdx + 1, cityIdx)
// 判断省市是否匹配
if (this.provinceName) {
if (this.provinceName !== province && this.cityName !== city) {
if (this.accountAddForm.provinceName) {
if (this.accountAddForm.provinceName !== province && this.accountAddForm.cityName !== city) {
this.$message.error('您选择的地址错误,请重新选择')
this.accountAddForm.merchantAddress = ''
return
}
}
this.dialogMapVisible = false
this.provinceName = province
this.cityName = city
this.accountAddForm.provinceName = province
this.accountAddForm.cityName = city
this.$refs.provinceForm.init(province, city)
const { provinceId, cityId } = this.$refs.provinceForm.provinceForm
this.accountAddForm.provinceId = provinceId
this.accountAddForm.cityId = cityId
},
// 当直接点击选择地址时,获取省市ID
init(province, city) {
this.$refs.provinceForm.init(province, city)
},
// 获取省
getProvince(provinceName, provinceId) {
console.log(this.accountAddForm.merchantAddress)
this.accountAddForm.merchantAddress = ''
console.log(this.accountAddForm.merchantAddress)
this.provinceName = provinceName
this.provinceId = provinceId
this.accountAddForm.provinceName = provinceName
this.accountAddForm.provinceId = provinceId
},
// 获取市
getCity(cityName, cityId) {
this.cityName = cityName
this.cityId = cityId
this.accountAddForm.cityName = cityName
this.accountAddForm.cityId = cityId
this.accountAddForm.merchantAddress = ''
},
delImg(index) {
......
......@@ -130,6 +130,10 @@ export default {
lat: null,
lng: null,
merchantAddress: null,
provinceName: null,
provinceId: null,
cityName: null,
cityId: null,
merchantName: null,
merchantAbbreviation: null,
merchantType: null,
......@@ -314,7 +318,7 @@ export default {
let businessScopeCustomize = this.businessScopeCustomize.map(item => item.name)
params.businessScopeCustomize = businessScopeCustomize.join(',')
params.merchantFiles = JSON.stringify(params.merchantFiles)
const merchantBrandList = this.$refs.baseInfoForm.$refs.brandListTree.getMerchantBrandList()
const merchantBrandList = this.$refs.baseInfoForm.$refs.brandListTree.getMerchantBrandList()
params.merchantBrandListJson = JSON.stringify(merchantBrandList)
Promise.all([pm1, pm2]).then(() => {
this.$apis.store.updateMerchant(params).then(res => {
......@@ -361,7 +365,7 @@ export default {
})
},
renderView(res) {
let { isloginName, bussinessBegintime, bussinessEndtime, lat, merchantBrandMain, businessType, lng, merchantAddress, merchantName, merchantAbbreviation, merchantType, merchantOrgcode, merchantLegalPerson, merchantLegalPersonPhone, residentContact, residentPhone, merchantLoginAccount, merchantLoginPassword, merchantAccountLevel, businessScope, businessScopeCustomize, merchantBrand, merchantFileResponses, merchantModel, accountTypes, accountType, accounttypeId, channelId, status, parentId } = res
let { isloginName, bussinessBegintime, bussinessEndtime, lat, merchantBrandMain, businessType, lng, merchantAddress, provinceName, cityName, provinceId, cityId, merchantName, merchantAbbreviation, merchantType, merchantOrgcode, merchantLegalPerson, merchantLegalPersonPhone, residentContact, residentPhone, merchantLoginAccount, merchantLoginPassword, merchantAccountLevel, businessScope, businessScopeCustomize, merchantBrand, merchantFileResponses, merchantModel, accountTypes, accountType, accounttypeId, channelId, status, parentId } = res
this.accountInfoForm.merchantLoginAccount = merchantLoginAccount
this.accountInfoForm.merchantLoginPassword = merchantLoginPassword
this.accountTypes = accountTypes
......@@ -407,6 +411,10 @@ export default {
lat,
lng,
merchantAddress,
provinceName,
cityName,
provinceId,
cityId,
merchantName,
merchantAbbreviation,
merchantType,
......@@ -423,6 +431,8 @@ export default {
accounttypeId: accountType,
merchantBrandMain
})
// 省市回显
this.$refs.baseInfoForm.init(this.accountAddForm.provinceName, this.accountAddForm.cityName)
merchantBrandMain = merchantBrandMain.replaceAll(';', ',').split(',')
this.$refs.baseInfoForm.checkBrandList(merchantBrandMain)
this.$refs.baseInfoForm.checkBusinessType(businessType)
......@@ -446,7 +456,7 @@ export default {
this.findAllDictData()
}
}
</script>
</script>
<style scoped lang="scss">
.tab-edit-status {
......@@ -611,4 +621,4 @@ export default {
z-index: 999;
box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
}
</style>
\ No newline at end of file
</style>
......@@ -24,10 +24,11 @@
<el-form-item size="small" label="营业时间" class="time-row">
<el-time-picker size="small" value-format="HH:mm:ss" is-range v-model="infoForm.bussinessTime" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围"></el-time-picker>
</el-form-item>
<el-form-item size="small" label="驻店电话">
<el-form-item size="small" label="驻店电话" style="position: relative;">
<el-input v-model="infoForm.residentPhone" placeholder="此电话会在小程序上显示,请填写真实有效的电话或手机号"></el-input>
<span>显示位置</span>
<div @click="showTelDia" class="show-address">显示位置</div>
</el-form-item>
<!-- <div @click="showTelDia" class="show-address">显示位置</div> -->
<el-form-item size="small" label="主营品牌" style="height: 500px">
<select-brand :brandListTree="brandListTree" ref="brandListTree"></select-brand>
</el-form-item>
......@@ -44,34 +45,40 @@
<el-button type="primary" @click="handleSave">提交</el-button>
<el-button @click="goback">取消</el-button>
</GLFooter>
<TelPosition ref="telDialog" :visible.sync="dialogTelVisible"></TelPosition>
</div>
</template>
<script>
import mapView from '@/components/mapView/index'
import SelectBrand from './selectBrand.vue'
import TelPosition from './telPosition.vue'
import Province from '@/components/province-city/index.vue'
export default {
name: 'EditInfo',
components: {
Province,
mapView,
SelectBrand
SelectBrand,
TelPosition
},
data() {
return {
checkedAll: false,
filterText: '',
dialogMapVisible: false,
dialogTelVisible: false,
mapHeight: 450,
infoForm: {
businessType: [1, 2, 3, 4, 5, 6],
bussinessTime: []
bussinessTime: [],
provinceName: '',
provinceId: '',
cityName: '',
cityId: ''
},
businessType: [],
brandListTree: [],
provinceName: '',
cityName: ''
brandListTree: []
}
},
mounted() {
......@@ -81,9 +88,8 @@ export default {
async brandList() {
this.$refs.brandListTree.loading = true
this.businessType = await this.$apis.store.findAllDictData({ dictType: 'business_type' })
console.log(this.businessType)
const infoForm = await this.$apis.store.findMerchantBaseInfo({ merchantId: this.$globalState.session.merchantId })
const { merchantAddress, lng, lat, id, merchantName, businessType, bussinessTime, bussinessBegintime, bussinessEndtime, channelId, merchantNo, merchantBrandMain } = infoForm
const { merchantAddress, provinceName, cityName, provinceId, cityId, lng, lat, id, merchantName, businessType, bussinessTime, bussinessBegintime, bussinessEndtime, channelId, merchantNo, merchantBrandMain } = infoForm
this.infoForm = {
merchantAddress,
lng,
......@@ -94,18 +100,21 @@ export default {
bussinessTime: [bussinessBegintime, bussinessEndtime],
merchantBrandMain,
merchantNo,
channelId
channelId,
provinceName,
cityName,
provinceId,
cityId
}
// 省市回显
this.$refs.provinceForm.init(this.infoForm.provinceName, this.infoForm.cityName)
if (!businessType) {
this.infoForm.businessType = [1, 2, 3, 4, 5, 6]
} else {
const businessType = this.infoForm.businessType.split(',')
this.infoForm.businessType = businessType.map(item => (item = parseInt(item)))
console.log(this.infoForm.businessType)
}
console.log(this.infoForm.businessType)
const brandListTree = await this.$apis.baseInfo.brandList({})
console.log(brandListTree)
brandListTree.forEach(item => {
let child = item.children
if (!child) return
......@@ -150,31 +159,44 @@ export default {
var province = address.slice(0, provinceIdx)
var city = address.slice(provinceIdx + 1, cityIdx)
// 判断省市是否匹配
if (this.provinceName) {
if (this.provinceName !== province && this.cityName !== city) {
if (this.infoForm.provinceName) {
if (this.infoForm.provinceName !== province && this.infoForm.cityName !== city) {
this.$message.error('您选择的地址错误,请重新选择')
this.infoForm.merchantAddress = ''
return
}
}
this.dialogMapVisible = false
this.provinceName = province
this.cityName = city
this.infoForm.provinceName = province
this.infoForm.cityName = city
// 当直接点击选择地址时,获取省市ID
this.$refs.provinceForm.init(province, city)
},
// 获取省
getProvince(val) {
this.provinceName = val
getProvince(provinceName, provinceId) {
this.infoForm.merchantAddress = ''
this.infoForm.provinceName = provinceName
this.infoForm.provinceId = provinceId
},
// 获取市
getCity(val) {
this.cityName = val
getCity(cityName, cityId) {
this.infoForm.cityName = cityName
this.infoForm.cityId = cityId
this.infoForm.merchantAddress = ''
},
// 展示驻点电话弹框
showTelDia() {
this.$refs.telDialog.init(this.infoForm.residentPhone)
},
handleSave() {
const params = this.infoForm
console.log(this.infoForm)
// 获取省市信息
const { provinceName, provinceId, cityName, cityId } = this.$refs.provinceForm.provinceForm
if (!params.provinceId) {
params.provinceName = provinceName
params.provinceId = provinceId
params.cityName = cityName
params.cityId = cityId
}
if (params.bussinessTime) {
params.bussinessBegintime = params.bussinessTime[0]
params.bussinessEndtime = params.bussinessTime[1]
......@@ -233,4 +255,13 @@ export default {
}
}
}
.show-address {
position: absolute;
right: -66px;
top: 50%;
transform: translateY(-50%);
font-size: 14px;
color: #5850ff;
cursor: pointer;
}
</style>
<template>
<div>
<el-dialog :visible.sync="dialogTelVisible" width="30%">
<div class="dialog-show">
<img src="@/assets/tel-show.png" alt="" />
<div class="tel-plus">联系电话:{{ residentPhone }}</div>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'telPositon',
data() {
return {
dialogTelVisible: false,
residentPhone: ''
}
},
methods: {
init(residentPhone) {
this.dialogTelVisible = true
residentPhone ? (this.residentPhone = residentPhone) : (this.residentPhone = '400-0000-400')
}
}
}
</script>
<style lang="scss" scoped>
.dialog-show {
position: relative;
width: 534px;
height: 650px;
.tel-plus {
position: absolute;
top: 395px;
left: 276px;
height: 25px;
font-size: 16px;
color: #656566;
font-family: PingFangSC-Regular, PingFang SC;
line-height: 25px;
}
}
/deep/ .el-dialog {
background-color: transparent;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0);
}
/deep/ .el-dialog__header {
border-bottom: transparent;
}
/deep/ .el-dialog__headerbtn .el-dialog__close {
color: #191717;
}
/deep/ .el-dialog__headerbtn {
font-size: 23px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!