优化店铺编辑页面
This commit is contained in:
parent
4296e12895
commit
8db7b22fd8
11
src/api/map.ts
Normal file
11
src/api/map.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export async function queryArea(str: string, region: string) {
|
||||||
|
let data = {keyword: str, region}
|
||||||
|
return request({
|
||||||
|
url: '/area/query',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
v-model="areaSelect"
|
v-model="areaSelect"
|
||||||
filterable
|
filterable
|
||||||
size="medium"
|
size="medium"
|
||||||
style="width: 300px"
|
style="width: 50%"
|
||||||
v-on:change="valchange">
|
v-on:change="valchange">
|
||||||
</el-cascader>
|
</el-cascader>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,53 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="createPost-container">
|
<div class="app-container">
|
||||||
<el-form
|
<el-form
|
||||||
ref="postForm"
|
ref="postForm"
|
||||||
:model="postForm"
|
:model="postForm"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
|
label-width="121px"
|
||||||
class="form-container"
|
class="form-container"
|
||||||
>
|
>
|
||||||
<sticky
|
|
||||||
:z-index="10"
|
|
||||||
:class-name="'sub-navbar '+postForm.status"
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
v-loading="loading"
|
|
||||||
style="margin-left: 10px;"
|
|
||||||
type="success"
|
|
||||||
@click="submitForm"
|
|
||||||
>
|
|
||||||
保存
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-loading="loading"
|
|
||||||
type="warning"
|
|
||||||
@click="draftForm"
|
|
||||||
>
|
|
||||||
Draft
|
|
||||||
</el-button>
|
|
||||||
</sticky>
|
|
||||||
|
|
||||||
<div class="createPost-main-container">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
style="margin-bottom: 40px;"
|
|
||||||
prop="name"
|
label="店铺名"
|
||||||
>
|
>
|
||||||
<material-input
|
<el-select
|
||||||
v-model="postForm.name"
|
v-model="postForm.name"
|
||||||
:maxlength="100"
|
:remote-method="queryShop"
|
||||||
name="name"
|
filterable
|
||||||
id="name"
|
default-first-option
|
||||||
required
|
remote
|
||||||
|
@change="areaSelectChange"
|
||||||
|
placeholder="搜索店铺"
|
||||||
|
allow-create
|
||||||
|
style="width: 50%"
|
||||||
>
|
>
|
||||||
店铺名
|
<el-option
|
||||||
</material-input>
|
v-for="(item, index) in shopListOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.showStr"
|
||||||
|
:value="item.title"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="区域"
|
label="区域"
|
||||||
>
|
>
|
||||||
@ -56,27 +38,28 @@
|
|||||||
v-on:area-change = "areaChange"
|
v-on:area-change = "areaChange"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
style="margin-bottom: 40px;"
|
label="详细地址"
|
||||||
prop="address"
|
prop="address"
|
||||||
>
|
>
|
||||||
<material-input
|
<el-input
|
||||||
v-model="postForm.address"
|
v-model="postForm.address"
|
||||||
:maxlength="1000"
|
|
||||||
name="address"
|
name="address"
|
||||||
id="address"
|
style="width: 50%"
|
||||||
required
|
required
|
||||||
>
|
/>
|
||||||
详细地址
|
</el-form-item>
|
||||||
</material-input>
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="submitForm"
|
||||||
|
>
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="onCancel">
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -91,6 +74,7 @@ import UploadImage from '@/components/UploadImage/index.vue'
|
|||||||
import RegionPicker from '@/components/RegionPicker/index.vue'
|
import RegionPicker from '@/components/RegionPicker/index.vue'
|
||||||
import { Form } from 'element-ui'
|
import { Form } from 'element-ui'
|
||||||
import { defaultShopData, getShop, saveShop } from '@/api/shop'
|
import { defaultShopData, getShop, saveShop } from '@/api/shop'
|
||||||
|
import { queryArea } from '@/api/map'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ShopEditor',
|
name: 'ShopEditor',
|
||||||
@ -130,6 +114,7 @@ export default class extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private tempTagView?: ITagView
|
private tempTagView?: ITagView
|
||||||
|
private shopListOptions = []
|
||||||
|
|
||||||
|
|
||||||
get lang() {
|
get lang() {
|
||||||
@ -197,7 +182,15 @@ export default class extends Vue {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private async onCancel() {
|
||||||
|
await this.$confirm('确认不保存当前店铺信息?', 'Warning', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
this.$store.dispatch("delView", this.$route)
|
||||||
|
this.$router.go(-1)
|
||||||
|
}
|
||||||
private draftForm() {
|
private draftForm() {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: 'The draft saved successfully',
|
message: 'The draft saved successfully',
|
||||||
@ -212,6 +205,38 @@ export default class extends Vue {
|
|||||||
this.postForm.areaStr = val
|
this.postForm.areaStr = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* begin of tencent map
|
||||||
|
*/
|
||||||
|
private async queryShop(val: string) {
|
||||||
|
if (!val || val.length < 2) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let { data } = await queryArea(val, '上海')
|
||||||
|
this.shopListOptions.length = 0
|
||||||
|
for(let d of data.records) {
|
||||||
|
d.showStr = `${d.title}(${d.city}-${d.district})`
|
||||||
|
}
|
||||||
|
this.shopListOptions = data.records
|
||||||
|
}
|
||||||
|
private areaSelectChange(val: any) {
|
||||||
|
let result
|
||||||
|
for (let d of this.shopListOptions) {
|
||||||
|
if (d.title == val) {
|
||||||
|
result = d
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(result)
|
||||||
|
if (result) {
|
||||||
|
this.postForm.address = result.address
|
||||||
|
this.postForm.areaCode = result.adcode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* end of tencent map
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user