<template>
|
<GlobalAlertWindow
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules" label-width="110px" label-suffix=":" inline>
|
<el-form-item label="城市名称" prop="cityId">
|
<!-- <el-input v-model="form.cityId" placeholder="请输入城市编码(关联areas)" v-trim/> -->
|
<div class="address">
|
<el-select v-model="form.provinceId" placeholder="请选择省份" @change="selectProvince">
|
<el-option
|
v-for="item in province"
|
:key="item.id"
|
:value="item.id"
|
:label="item.name"
|
></el-option>
|
</el-select>
|
<el-select v-model="form.cityId" placeholder="请选择城市">
|
<el-option
|
v-for="item in cities"
|
:key="item.id"
|
:value="item.id"
|
:label="item.name"
|
></el-option>
|
</el-select>
|
</div>
|
</el-form-item>
|
<el-form-item label="排序码(升序)" prop="sortnum">
|
<el-input v-model="form.sortnum" placeholder="请输入排序码(升序)" v-trim/>
|
</el-form-item>
|
</el-form>
|
</GlobalAlertWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalAlertWindow from '@/components/common/GlobalAlertWindow'
|
import { listByParentId } from '@/api/business/areas'
|
export default {
|
name: 'OperaHotCityWindow',
|
extends: BaseOpera,
|
components: { GlobalAlertWindow },
|
data () {
|
const newRule = (rule, value, callback) => {
|
if (!this.form.provinceId) {
|
callback(new Error('请先选择省份'))
|
} else if (!this.form.cityId) {
|
callback(new Error('请选择城市'))
|
} else {
|
callback()
|
}
|
}
|
return {
|
// 表单数据
|
form: {
|
id: null,
|
creator: '',
|
createDate: '',
|
editor: '',
|
editDate: '',
|
isdeleted: '',
|
info: '',
|
provinceId: '',
|
cityId: '',
|
sortnum: ''
|
},
|
province: [],
|
cities: [],
|
// 验证规则
|
rules: {
|
cityId: [
|
{ required: true, validator: newRule, trigger: 'change' }
|
]
|
}
|
}
|
},
|
created () {
|
this.config({
|
api: '/business/hotCity',
|
'field.id': 'id'
|
})
|
listByParentId({ type: 0, parentId: '' })
|
.then(data => {
|
this.province = data
|
})
|
},
|
methods: {
|
selectProvince (val) {
|
this.form.cityId = ''
|
this.cities = []
|
listByParentId({ type: 1, parentId: val })
|
.then(data => {
|
this.cities = data
|
})
|
.catch(e => {
|
this.$tip.error(e)
|
})
|
},
|
numInput () {
|
// =""
|
this.form.sortnum = this.form.sortnum.replace(/^(0+)|[^\d]+/g, '')
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "@/assets/style/alertstyle.scss";
|
|
::v-deep .el-select {
|
width: 100%;
|
.el-input__inner {
|
width: 100%;
|
}
|
}
|
|
</style>
|