Merge pull request #841 from wsd000/feat_license_plate_keyboard
feat: 修复打包及组件默认值的问题ard
This commit is contained in:
commit
f6d2da1665
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="md-license-plate-keyboard">
|
<div class="md-license-plate-keyboard">
|
||||||
<div v-if="keyboardType === 1">
|
<div v-if="keyboardType === 1">
|
||||||
<shortcut-view
|
<md-shortcut-row
|
||||||
:shortcuts="shortcuts"
|
:shortcuts="shortcuts"
|
||||||
@enter="$_onEnter"
|
@enter="$_onEnter"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<keyboard-view
|
<md-mixed-key-board
|
||||||
:mixedKeyboard="mixedKeyboard"
|
:mixedKeyboard="mixedKeyboard"
|
||||||
@enter="$_onEnter"
|
@enter="$_onEnter"
|
||||||
@delete="$_onDelete"
|
@delete="$_onDelete"
|
||||||
|
@ -17,15 +17,15 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
import keyboardView from './key-board-view.vue'
|
<script>
import MixedKeyBoard from './mixed-key-board'
|
||||||
import shortcutView from './short-cut-view.vue'
|
import ShortcutRow from './short-cut-row'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'md-license-plate-keyboard',
|
name: 'md-license-plate-keyboard',
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
keyboardView,
|
[MixedKeyBoard.name]: MixedKeyBoard,
|
||||||
shortcutView,
|
[ShortcutRow.name]: ShortcutRow,
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
disabled: item.disabled
|
disabled: item.disabled
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<img v-if="item.type === 'delete'" src="./assets/close.png"/>
|
|
||||||
<div v-if="item.type === 'confirm' && item.text">{{ item.text }}</div>
|
<div v-if="item.type === 'confirm' && item.text">{{ item.text }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -85,10 +84,9 @@
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
margin: 0px 0px 10px 10px;
|
margin: 0px 0px 10px 10px;
|
||||||
&.delete{
|
&.delete{
|
||||||
img{
|
background: url(../_style/images/license-keyboard-del.png) center no-repeat;
|
||||||
width: 40px;
|
background-color: #FFFFFF;
|
||||||
height: 40px;
|
background-size: 40px 40px;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
&.confirm{
|
&.confirm{
|
||||||
width: 212px;
|
width: 212px;
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<md-license-plate :stackViewBody="'#licensePlateContainer'"></md-license-plate>
|
<md-license-plate :defaultValue="defaultValue"></md-license-plate>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -12,7 +12,14 @@ export default {
|
||||||
[LicensePlate.name]: LicensePlate,
|
[LicensePlate.name]: LicensePlate,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {}
|
return {
|
||||||
|
defaultValue: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// this.defaultValue = '23338888888'
|
||||||
|
// },10000)
|
||||||
},
|
},
|
||||||
methods: {},
|
methods: {},
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
class="md-license-plate-input-container division"
|
class="md-license-plate-input-container division"
|
||||||
:id="inputViewId"
|
:id="inputViewId"
|
||||||
>
|
>
|
||||||
<license-plate-input
|
<md-license-plate-input
|
||||||
:keyArray="keyArray"
|
:keyArray="keyArray"
|
||||||
:selectedIndex="dyCurrentIndex"
|
:selectedIndex="dyCurrentIndex"
|
||||||
@keyMapping="keyMapping"
|
@keyMapping="keyMapping"
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
class="md-license-plate-keyboard-container division"
|
class="md-license-plate-keyboard-container division"
|
||||||
:id="keyboardViewId"
|
:id="keyboardViewId"
|
||||||
>
|
>
|
||||||
<license-plate-keyboard
|
<md-license-plate-keyboard
|
||||||
:keyboard="dyKeyboard"
|
:keyboard="dyKeyboard"
|
||||||
@enter="$_onEnter"
|
@enter="$_onEnter"
|
||||||
@delete="$_onDelete"
|
@delete="$_onDelete"
|
||||||
|
@ -41,14 +41,14 @@
|
||||||
></md-popup-title-bar>
|
></md-popup-title-bar>
|
||||||
<div class="md-popup-content">
|
<div class="md-popup-content">
|
||||||
<div class="md-license-plate-input-container popUp">
|
<div class="md-license-plate-input-container popUp">
|
||||||
<license-plate-input
|
<md-license-plate-input
|
||||||
:keyArray="keyArray"
|
:keyArray="keyArray"
|
||||||
:selectedIndex="dyCurrentIndex"
|
:selectedIndex="dyCurrentIndex"
|
||||||
@keyMapping="keyMapping"
|
@keyMapping="keyMapping"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-license-plate-keyboard-container popUp">
|
<div class="md-license-plate-keyboard-container popUp">
|
||||||
<license-plate-keyboard
|
<md-license-plate-keyboard
|
||||||
:keyboard="dyKeyboard"
|
:keyboard="dyKeyboard"
|
||||||
@enter="$_onEnter"
|
@enter="$_onEnter"
|
||||||
@delete="$_onDelete"
|
@delete="$_onDelete"
|
||||||
|
@ -61,8 +61,8 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
import licensePlateKeyboard from '../license-plate-keyboard'
|
<script>
import LicensePlateKeyboard from '../license-plate-keyboard'
|
||||||
import licensePlateInput from '../license-plate-input'
|
import LicensePlateInput from '../license-plate-input'
|
||||||
import Popup from '../popup'
|
import Popup from '../popup'
|
||||||
import PopupTitlebar from '../popup/title-bar'
|
import PopupTitlebar from '../popup/title-bar'
|
||||||
import {directiveInit, queryCurParentNode, unique} from './util'
|
import {directiveInit, queryCurParentNode, unique} from './util'
|
||||||
|
@ -71,8 +71,8 @@ export default {
|
||||||
name: 'md-license-plate',
|
name: 'md-license-plate',
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
licensePlateKeyboard,
|
[LicensePlateKeyboard.name]: LicensePlateKeyboard,
|
||||||
licensePlateInput,
|
[LicensePlateInput.name]: LicensePlateInput,
|
||||||
[Popup.name]: Popup,
|
[Popup.name]: Popup,
|
||||||
[PopupTitlebar.name]: PopupTitlebar,
|
[PopupTitlebar.name]: PopupTitlebar,
|
||||||
},
|
},
|
||||||
|
@ -302,7 +302,7 @@ export default {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// 用户输入的车牌数据
|
// 用户输入的车牌数据
|
||||||
keyArray: (this.defaultValue && this.defaultValue.split('')) || ['', '', '', '', '', '', '', ''],
|
keyArray: ['', '', '', '', '', '', '', ''],
|
||||||
selectedIndex: 0, // 当前用户输入框已选中的序号
|
selectedIndex: 0, // 当前用户输入框已选中的序号
|
||||||
showDivisionKeyboard: false,
|
showDivisionKeyboard: false,
|
||||||
inputViewId: unique() + '_divisionInput',
|
inputViewId: unique() + '_divisionInput',
|
||||||
|
@ -367,6 +367,16 @@ export default {
|
||||||
keyboardType,
|
keyboardType,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 健值为null特殊处理
|
||||||
|
keyArrayCopy() {
|
||||||
|
return this.keyArray.map(item => {
|
||||||
|
if (item) {
|
||||||
|
return item
|
||||||
|
} else {
|
||||||
|
return ' '
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
@ -380,10 +390,10 @@ export default {
|
||||||
if (!this.showDivisionKeyboard) {
|
if (!this.showDivisionKeyboard) {
|
||||||
this.showDivisionKeyboard = true
|
this.showDivisionKeyboard = true
|
||||||
// 抛出展示分离键盘事件
|
// 抛出展示分离键盘事件
|
||||||
this.$emit('sdKeyboard')
|
this.$emit('sdKeyboard', this.keyboardViewId)
|
||||||
}
|
}
|
||||||
// 顺序填写,不可无序点击
|
// 顺序填写,不可无序点击
|
||||||
if (!this.keyArray[index + 1] && !this.keyArray[index - 1]) {
|
if (!this.keyArray[index + 1] && !this.keyArray[index - 1] && index > 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.selectedIndex = index
|
this.selectedIndex = index
|
||||||
|
@ -423,7 +433,7 @@ export default {
|
||||||
if (this.modeShow === 'division') {
|
if (this.modeShow === 'division') {
|
||||||
this.hideDivisionKeyboard()
|
this.hideDivisionKeyboard()
|
||||||
}
|
}
|
||||||
this.$emit('confirm', this.keyArray.join(''))
|
this.$emit('confirm', this.keyArrayCopy.join(''))
|
||||||
},
|
},
|
||||||
// 隐藏分离键盘
|
// 隐藏分离键盘
|
||||||
hideDivisionKeyboard(e) {
|
hideDivisionKeyboard(e) {
|
||||||
|
@ -434,7 +444,7 @@ export default {
|
||||||
if (this.showDivisionKeyboard && !isKeyboard) {
|
if (this.showDivisionKeyboard && !isKeyboard) {
|
||||||
this.showDivisionKeyboard = false
|
this.showDivisionKeyboard = false
|
||||||
// 抛出隐藏分离键盘事件
|
// 抛出隐藏分离键盘事件
|
||||||
this.$emit('hdKeyboard')
|
this.$emit('hdKeyboard', this.keyArrayCopy.join(''))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -447,6 +457,28 @@ export default {
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.modeShow === 'division' && document.removeEventListener('click', this.hideDivisionKeyboard)
|
this.modeShow === 'division' && document.removeEventListener('click', this.hideDivisionKeyboard)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
defaultValue: {
|
||||||
|
handler(newVal) {
|
||||||
|
if (newVal !== '') {
|
||||||
|
const defaultValueArray = this.defaultValue.split('')
|
||||||
|
const keyArrayCopy = JSON.parse(JSON.stringify(this.keyArray))
|
||||||
|
|
||||||
|
keyArrayCopy.forEach((item, index) => {
|
||||||
|
if (defaultValueArray[index]) {
|
||||||
|
keyArrayCopy[index] = defaultValueArray[index]
|
||||||
|
} else {
|
||||||
|
keyArrayCopy[index] = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.keyArray = keyArrayCopy
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue