Skip to content

Commit

Permalink
新增参数provinceDisable、cityDisable、areaDisable,分开控制省、市、县的禁用
Browse files Browse the repository at this point in the history
  • Loading branch information
kent666a committed Oct 12, 2018
1 parent 2f3f2ae commit b37258c
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 5 deletions.
23 changes: 22 additions & 1 deletion examples/components/Attributes.vue
Expand Up @@ -44,7 +44,28 @@
</tr>
<tr>
<td><strong>disabled</strong></td>
<td><strong>是否禁用(选填,默认 false,且 type='mobile' 时无效)</strong></td>
<td><strong>是否禁用(选填,默认 false,且 type='mobile' 时无效,当disabled=true时province-disabled、city-disabled、area-disabled均无效)</strong></td>
<td>Boolean</td>
<td>true, false</td>
<td>false</td>
</tr>
<tr>
<td><strong>province-disabled</strong></td>
<td><strong>是否禁用省(选填,默认 false,且 type='mobile' 时无效)</strong></td>
<td>Boolean</td>
<td>true, false</td>
<td>false</td>
</tr>
<tr>
<td><strong>city-disabled</strong></td>
<td><strong>是否禁用市(选填,默认 false,且 type='mobile' 时无效)</strong></td>
<td>Boolean</td>
<td>true, false</td>
<td>false</td>
</tr>
<tr>
<td><strong>area-disabled</strong></td>
<td><strong>是否禁用区、县(选填,默认 false,且 type='mobile' 时无效)</strong></td>
<td>Boolean</td>
<td>true, false</td>
<td>false</td>
Expand Down
3 changes: 3 additions & 0 deletions examples/components/BaseUsage/BaseUsage.vue
Expand Up @@ -8,6 +8,7 @@
<only-province></only-province>
<trigger-event></trigger-event>
<reset-button></reset-button>
<disabled></disabled>
</div>
</template>

Expand All @@ -19,9 +20,11 @@ import HideArea from './HideArea'
import OnlyProvince from './OnlyProvince'
import TriggerEvent from './TriggerEvent'
import ResetButton from './ResetButton'
import Disabled from "./Disabled";
export default {
components: {
Disabled,
Basic,
Placeholders,
DefaultValue,
Expand Down
50 changes: 50 additions & 0 deletions examples/components/BaseUsage/Disabled.vue
@@ -0,0 +1,50 @@
<template>
<div class="row">
<div class="example">
<h5>Disabled Value</h5>
<div class="example-box">
<div class="box-left d-flex align-items-baseline">
<div class="col-md-7">
<v-distpicker :province="select.province" :city="select.city" :area="select.area"
@province="selectProvince" @city="selectCity" @area="selectArea"
:province-disabled="true" :city-disabled="true"></v-distpicker>
</div>
<div class="content-show col-md-5">
<pre><code>{{ select }}</code></pre>
</div>
</div>
<div class="box-footer" @click="showCode = !showCode">
{{ showCode ? 'Hide Code' : 'Show Code' }}
</div>
</div>
</div>
</div>
</template>

<script>
import VDistpicker from '../../../src/Distpicker'
export default {
components: {VDistpicker},
data() {
return {
showCode: false,
select: {province: 440000, city: '广州市', area: '海珠区'},
}
},
methods: {
selectProvince(value) {
this.select.province = value.value
console.log(value);
},
selectCity(value) {
this.select.city = value.value
console.log(value);
},
selectArea(value) {
this.select.area = value.value
console.log(value);
},
},
}
</script>
14 changes: 10 additions & 4 deletions src/Distpicker.vue
@@ -1,7 +1,7 @@
<template>
<div class="distpicker-address-wrapper">
<template v-if="type != 'mobile'">
<select @change="getCities" v-model="currentProvince" :disabled="disabled">
<select @change="getCities" v-model="currentProvince" :disabled="disabled || provinceDisabled">
<option :value="placeholders.province">{{ placeholders.province }}</option>
<option v-for="(item, index) in provinces"
:value="item"
Expand All @@ -10,15 +10,15 @@
</option>
</select>
<template v-if="!onlyProvince">
<select @change="getAreas" v-model="currentCity" :disabled="disabled">
<select @change="getAreas" v-model="currentCity" :disabled="disabled || cityDisabled">
<option :value="placeholders.city">{{ placeholders.city }}</option>
<option v-for="(item, index) in cities"
:value="item"
:key="index">
{{ item }}
</option>
</select>
<select v-if="!hideArea" v-model="currentArea" :disabled="disabled">
<select v-if="!hideArea" v-model="currentArea" :disabled="disabled || areaDisabled">
<option :value="placeholders.area">{{ placeholders.area }}</option>
<option v-for="(item, index) in areas "
:value="item"
Expand Down Expand Up @@ -73,7 +73,7 @@
<script>
import DISTRICTS from './districts';
const DEFAULT_CODE = 100000
const DEFAULT_CODE = 100000;
export default {
name: 'v-distpicker',
Expand All @@ -96,6 +96,9 @@ export default {
}
},
disabled: { type: Boolean, default: false },
provinceDisabled: { type: Boolean, default: false },
cityDisabled: { type: Boolean, default: false },
areaDisabled: { type: Boolean, default: false },
addressHeader: { type: String, default: 'address-header' },
addressContainer: { type: String, default: 'address-container' },
},
Expand Down Expand Up @@ -378,4 +381,7 @@ export default {
}
}
}
.disabled-color{
background: #f8f8f8;
}
</style>

0 comments on commit b37258c

Please sign in to comment.