master
lion 3 years ago
parent 5ad2c1f32a
commit 3308951779

@ -79,7 +79,7 @@
.u-popup__content {
background: linear-gradient(0deg, #ffffff 85%, #E4C8A2);
background: linear-gradient(0deg, #ffffff 85%, #044ed7);
}
.mpopup-content {

@ -0,0 +1,196 @@
<template>
<view>
<u-popup :show="show" @close="cancel">
<view class="title" style="font-size: 50rpx;text-align: center;padding: 20rpx 0;">{{popupTitle}}</view>
<view style="padding: 20rpx;">
<u-search v-if="showSearch" @custom="search" @search="search" :placeholder="placeholder"
v-model="keyword"></u-search>
<u-gap v-if="showSearch" height="15"></u-gap>
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltolower="$emit('lower')">
<!--单选-->
<u-radio-group v-if="type == 'radio'" :borderBottom="true" iconPlacement="right" placement="column"
@change="groupChange" v-model="radioValue">
<u-radio :customStyle="{marginBottom: '12px'}" v-for="(item, index) in dataLists" :key="index"
:label="item[labelKey]" :name="index">
</u-radio>
</u-radio-group>
<!--多选-->
<u-checkbox-group v-if="type == 'checkbox'" :borderBottom="true" placement="column"
iconPlacement="right" @change="checkboxChange" v-model="checkboxValue">
<u-checkbox :customStyle="{marginBottom: '12px',paddingBottom:'12px'}"
v-for="(item, index) in dataLists" :key="index" :label="item[labelKey]" :name="index">
</u-checkbox>
</u-checkbox-group>
</scroll-view>
<u-gap height="45"></u-gap>
<view class="bottons">
<u-row>
<u-col customStyle="padding:0 10rpx 20rpx 20rpx" span="6">
<u-button @click="cancel"></u-button>
</u-col>
<u-col customStyle="padding:0 20rpx 20rpx 10rpx" span="6">
<u-button @click="submit" type="primary" throttleTime="1000"
:disabled="(JSON.stringify(radioData) === '{}') && (checkboxData.length === 0)">确认</u-button>
</u-col>
</u-row>
</view>
</view>
</u-popup>
</view>
</template>
<script>
/**
* 公共选择下拉框基于uview支持下拉加载列表搜索单选多选
* @author qianziyu
* @description 弹出层选择器基于uview中u-popup实现
* @property {Array} dataLists 数据列表
* @property {String} name 列表显示的字段名
* @property {Boolean} show 是否展示弹窗 (默认 false )
* @property {String} type 选择类型 单选多选 (默认 单选 )
* @property {Boolean} showSearch 是否显示搜索框 (默认 true )
* @property {String} popupTitle 列表标题
* @property {String} placeholder 搜索框placeholder
* @event {Function} search 搜索事件返回keyword
* @event {Function} lower 滑动到底部触发用于下拉加载新数据
* @event {Function} cancel 组件关闭事件
* @event {Function} submit 提交按钮,返回选中的列表数据
* @example <common-select :show="show" :popupTitle="popupTitle" @cancel="show=false" @search="selectSearch" name="cworkStationName" @submit="onsubmit"
:dataLists="dataLists" placeholder="输入工站名称搜索"></common-select>
*/
export default {
name: "qianziyu-select",
props: {
dataLists: {
default: {},
type: Array
},
name: {
default: 'name',
},
show: {
default: false,
type: Boolean
},
type: {
default: 'radio',
type: String
},
showSearch: {
default: true,
type: Boolean
},
popupTitle: {
default: '列表选择',
type: String
},
placeholder: {
default: '请输入搜索内容'
},
labelKey: {
default: 'name',
type: String
}
},
data() {
return {
keyword: '',
scrollTop: 0,
checkboxData: [],
checkboxValue: [],
radioData: {},
radioValue: ''
};
},
methods: {
checkboxChange(n) {
this.checkboxData = []
n.forEach(key => {
this.checkboxData.push(this.dataLists[key])
})
},
//
groupChange(n) {
this.radioData = this.dataLists[n]
},
//
search() {
this.radioData = {}
this.checkboxData = []
this.radioValue = ''
this.checkboxValue = []
this.$emit('search', this.keyword)
},
//
cancel() {
this.keyword = ''
this.$emit('cancel')
},
//
submit() {
if (this.type == 'radio') {
if (JSON.stringify(this.radioData) == '{}') {
uni.$u.toast('请选择数据')
return;
}
this.keyword = ''
this.$emit('submit', this.radioData)
} else if (this.type == 'checkbox') {
if (this.checkboxData.length == 0) {
uni.$u.toast('请选择数据')
return;
}
this.keyword = ''
this.$emit('submit', this.checkboxData)
}
}
}
}
</script>
<style scoped>
/deep/ .u-popup__content {
background-color: #044ed7;
}
/deep/ .u-popup__content .title {
border-bottom: 1px solid #f7f7f7;
text-align: center;
font-weight: bold;
font-size: 50rpx;
text-align: center;
padding: 20rpx 0;
}
/* .u-popup {
v:deep {
border-bottom: 1px solid #f7f7f7;
padding: 20rpx;
text-align: center;
font-weight: bold;
font-size: 50rpx;
text-align: center;
padding: 10px 0;
}
} */
.scroll-Y {
height: 650rpx;
}
.bottons {
background-color: white;
position: fixed;
left: 0;
bottom: 0;
right: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
}
</style>

@ -1,4 +1,5 @@
<template>
<page-meta :page-style="'overflow:'+(adminListShow?'hidden':'visible')"></page-meta>
<view class="containers">
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
@ -6,7 +7,7 @@
<uni-forms ref="formdata" :model="form" :rules="rules" labelWidth="100px">
<view class="formtext">拜访信息</view>
<uni-forms-item label="到访日期" required name="date">
<uni-datetime-picker type="date" return-type="string" v-model="form.date" />
<uni-datetime-picker type="date" :start="toadyStart" return-type="string" v-model="form.date" />
</uni-forms-item>
<uni-forms-item label="到访时段" required name="visit_time_id">
<uni-data-checkbox v-model="form.visit_time_id" :localdata="visitTime"
@ -22,13 +23,13 @@
</uni-forms-item>
<uni-forms-item label="施工开始时段" v-if="form.type==2">
<uni-datetime-picker type="date" return-type="string" v-model="form.work_start_time" />
</uni-forms-item>
<uni-forms-item label="施工结束时段" v-if="form.type==2">
<uni-datetime-picker type="date" return-type="string" v-model="form.work_end_time" />
</uni-forms-item>
<uni-forms-item label="车牌号" v-if="form.type==3">
<uni-easyinput v-model="form.plate" placeholder="请输入车牌号" />
<uni-easyinput @focus="plateShow=true" v-model.trim="form.plate" placeholder="请输入车牌号" />
<plate-input v-if="plateShow" :plate="form.plate" @export="setPlate" @close="plateShow = false" />
</uni-forms-item>
<uni-forms-item label="备注">
<uni-easyinput type="textarea" v-model="form.remark" placeholder="请输入自我备注" />
@ -40,18 +41,20 @@
<uni-forms-item label="联系电话" required name="mobile">
<uni-easyinput v-model="form.mobile" placeholder="请输入联系电话" />
</uni-forms-item>
<uni-forms-item label="证件类型">
<uni-forms-item label="证件类型" required name="credent">
<uni-data-select v-model="form.credent" :localdata="credentList">
</uni-data-select>
</uni-forms-item>
<uni-forms-item label="证件号码">
<uni-forms-item label="证件号码" required name="idcard">
<uni-easyinput type="idcard" v-model="form.idcard" placeholder="请输入证件号码" />
</uni-forms-item>
<uni-forms-item label="单位名称">
<uni-forms-item label="单位名称" required name="company_name">
<uni-easyinput v-model="form.company_name" placeholder="请输入单位名称" />
</uni-forms-item>
<uni-forms-item label="到访车辆" v-if="form.type!=3">
<uni-easyinput v-model="form.cars" placeholder="请输入到访车辆" />
<uni-easyinput v-model="form.cars" @focus="plateShow=true" v-model.trim="form.cars"
placeholder="请输入到访车辆" />
<plate-input v-if="plateShow" :plate="form.cars" @export="setCars" @close="plateShow = false" />
</uni-forms-item>
<template v-if="form.type!=3">
<view class="formtext" style="display: flex;justify-content: space-between;">
@ -103,12 +106,17 @@
</template>
<view class="formtext">被访人信息</view>
<uni-forms-item label="被访人">
<uni-data-select v-model="form.accept_admin_id" :localdata="adminList">
</uni-data-select>
<!-- <uni-data-select @focus="adminListShow=true" v-model="form.accept_admin_id" :localdata="adminList">
</uni-data-select> -->
<uni-easyinput @clear="clearAccept('accept')" v-model="acceptName" @focus="adminListShowOpen('accept')" placeholder="请选择联系人员" />
<qianziyu-select :show="adminListShow" type="radio" :popupTitle="'联系人员'" name="cworkStationName"
:dataLists="adminList" placeholder="输入关键词搜索" @search="selectSearch"
@submit="submitAccept" @cancel="cancelAccept"/>
</uni-forms-item>
<uni-forms-item label="收货人" v-if="form.type==3">
<uni-data-select v-model="form.accept_goods_admin_id" :localdata="adminList">
</uni-data-select>
<!-- <uni-data-select v-model="form.accept_goods_admin_id" :localdata="adminList">
</uni-data-select> -->
<uni-easyinput @clear="clearAccept('goods')" v-model="goodsName" @focus="adminListShowOpen('goods')" placeholder="请选择联系人员" />
</uni-forms-item>
</uni-forms>
<button type="primary" style="background-color: #044ed7;" @click="saveFormgoStudy">{{goStudy}}</button>
@ -116,19 +124,19 @@
<!-- 随访人员弹出 -->
<uni-drawer ref="showRight" mode="right" :mask-click="true">
<uni-forms ref="form" :model="follw_people_obj" labelWidth="80px">
<uni-forms-item label="姓名">
<uni-forms ref="peopleform" :model="follw_people_obj" :rules="peoplerules" labelWidth="80px">
<uni-forms-item label="姓名" required name='name'>
<uni-easyinput v-model="follw_people_obj.name" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item label="联系电话">
<uni-forms-item label="联系电话" required name='mobile'>
<uni-easyinput v-model="follw_people_obj.mobile" placeholder="请输入联系电话" />
</uni-forms-item>
<uni-forms-item label="证件类型">
<uni-forms-item label="证件类型" required name='credent'>
<uni-data-select @change="chooseCredent" v-model="follw_people_obj.credent"
:localdata="credentList">
</uni-data-select>
</uni-forms-item>
<uni-forms-item label="证件号码">
<uni-forms-item label="证件号码" required name='idcard'>
<uni-easyinput type="idcard" v-model="follw_people_obj.idcard" placeholder="请输入证件号码" />
</uni-forms-item>
</uni-forms>
@ -143,7 +151,13 @@
</template>
<script>
import plateInput from '@/uni_modules/uni-plate-input/uni-plate-input.vue'
import qianziyuSelect from '@/components/qianziyu-select/qianziyu-select.vue'
export default {
components: {
plateInput,
qianziyuSelect
},
data() {
return {
steps: [{
@ -154,6 +168,13 @@
title: '完成'
}],
stepActive: 0,
toadyStart: '',
plateShow: false,
adminListShow: false,
adminKeyword: '',
acceptType: "",
acceptName: "",
goodsName: '',
form: {
type: 1,
date: "",
@ -176,7 +197,12 @@
accept_admin_id: "",
accept_goods_admin_id: ""
},
follw_people_obj: {},
follw_people_obj: {
name: "",
mobile: "",
credent: 1,
idcard: "",
},
follow_people_index: -1,
rules: {
date: {
@ -212,6 +238,59 @@
errorMessage: '联系号码格式错误'
}]
},
credent: {
rules: [{
required: true,
errorMessage: '请选择身份证类型'
}]
},
idcard: {
rules: [{
required: true,
errorMessage: '身份证号码不能为空'
}, {
pattern: '^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]',
errorMessage: '身份证格式错误'
}]
},
compamy_name: {
rules: [{
required: true,
errorMessage: '单位名称不能为空'
}]
}
},
peoplerules: {
name: {
rules: [{
required: true,
errorMessage: '随访人姓名不能为空'
}]
},
mobile: {
rules: [{
required: true,
errorMessage: '联系电话不能为空'
}, {
pattern: '^[1][3-9][\\d]{9}',
errorMessage: '联系号码格式错误'
}]
},
credent: {
rules: [{
required: true,
errorMessage: '请选择身份证类型'
}]
},
idcard: {
rules: [{
required: true,
errorMessage: '身份证号码不能为空'
}, {
pattern: '^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]',
errorMessage: '身份证格式错误'
}]
}
},
//
visitTime: [],
@ -233,22 +312,22 @@
id: 1,
value: '是'
}],
adminList: [],
isCall:'', //
goStudy:'去学习'
adminList: [],
isCall: '', //
goStudy: '去学习'
}
},
onLoad(options) {
this.form.type = options.type
// uni.navigateTo({
// url: '/pages/visit/study?type='+this.form.type
// })
// return
this.isCall = options.iscall?options.iscall:''
this.goStudy = this.isCall=='call'?'提交':'去学习'
this.form.audit_status = this.isCall=='call'?1:0
onLoad(options) {
this.toadyStart = new Date()
this.form.type = options.type
// uni.redirectTo({
// url: '/pages/visit/study?type='+this.form.type
// })
// return
this.isCall = options.iscall ? options.iscall : ''
this.goStudy = this.isCall == 'call' ? '提交' : '去学习'
this.form.audit_status = this.isCall == 'call' ? 1 : 0
this.getVisitArea()
this.getVisitTime()
this.getReason()
@ -256,6 +335,49 @@
},
onReady() {},
methods: {
adminListShowOpen(type) {
this.acceptType = type
this.adminKeyword = ""
this.getAdminList()
this.adminListShow = true
},
cancelAccept() {
console.log('123')
this.adminKeyword = ""
this.adminListShow = false
},
selectSearch(e) {
this.adminKeyword = e
this.getAdminList()
},
clearAccept(type){
if (type == 'accept') {
this.form.accept_admin_id = ''
this.acceptName = ''
} else {
this.form.accept_goods_admin_id = ''
this.goodsName = ''
}
},
submitAccept(e) {
if (this.acceptType == 'accept') {
this.form.accept_admin_id = e.id
this.acceptName = e.name
} else {
this.form.accept_goods_admin_id = e.id
this.goodsName = e.name
}
this.adminListShow = false
},
setCars(e) {
this.form.cars = e
this.plateShow = false
console.log(e)
},
setPlate(e) {
this.form.plate = e
this.plateShow = false
},
//
async getVisitArea() {
let that = this
@ -316,17 +438,11 @@
api: '/api/admin/other/admin-user-list',
data: {
page_size: 99,
page: 1
page: 1,
keyword: this.adminKeyword
},
utilSuccess: function(res) {
let arr = []
for (var m of res.data) {
arr.push({
text: m.name,
value: m.id
})
}
that.adminList = arr
that.adminList = res.data
},
utilFail: function(res) {}
})
@ -347,56 +463,64 @@
this.$refs.showRight.close()
},
pushFollowPeople() {
if (this.follow_people_index > -1) {
this.form.follw_people[this.follow_people_index] = this.follw_people_obj
} else {
this.form.follw_people.push(this.follw_people_obj)
}
this.follow_people_index = -1
this.$refs.showRight.close()
console.log('this.follw_people_obj', this.follw_people_obj)
this.$refs['peopleform'].validate().then(res => {
if (this.follow_people_index > -1) {
this.form.follw_people[this.follow_people_index] = this.follw_people_obj
} else {
this.form.follw_people.push(this.follw_people_obj)
}
this.follow_people_index = -1
this.$refs.showRight.close()
}).catch(err => {
console.log('err', err);
})
},
//
saveFormgoStudy() {
console.log("form", this.form)
this.$refs['formdata'].validate().then(res => {
if(this.isCall==='call'){
this.submitForm()
return
this.$refs['formdata'].validate().then(res => {
if (this.isCall === 'call') {
this.submitForm()
return
}
uni.setStorageSync('formdata',this.form)
uni.navigateTo({
uni.setStorageSync('formdata', this.form)
uni.redirectTo({
url: '/pages/visit/study?type=' + this.form.type
})
}).catch(err => {
console.log('err', err);
})
},
submitForm() {
let that = this
this.util.request({
api: '/api/admin/visit/save',
method: "POST",
requestType:'bd',
data: that.form,
utilSuccess: function(res) {
uni.showToast({
title: res.msg,
duration: 2000,
icon: 'none'
})
// uni.removeStorageSync('formData')
uni.navigateTo({
url:'/pages/visit/successform?iscall=call'
})
},
utilFail: function(res) {
uni.showToast({
title: res.errmsg,
duration: 2000,
icon: 'none'
})
}
})
},
submitForm() {
let that = this
this.util.request({
api: '/api/admin/visit/save',
method: "POST",
requestType: 'bd',
data: that.form,
utilSuccess: function(res) {
uni.showToast({
title: res.msg,
duration: 2000,
icon: 'none'
})
// uni.removeStorageSync('formData')
uni.redirectTo({
url: '/pages/visit/successform?iscall=call'
})
},
utilFail: function(res) {
uni.showToast({
title: res.errmsg,
duration: 2000,
icon: 'none'
})
}
})
}
}
}
@ -425,4 +549,4 @@
/deep/ .uni-drawer__content {
padding: 40rpx
}
</style>
</style>

@ -109,8 +109,8 @@
}
}
that.showSwiperFlag = that.picList.length==0? 1 : 0
that.studyMin = res.minute * 60
// that.studyMin = .1 * 60
// that.studyMin = res.minute * 60
that.studyMin = .1 * 60
},
utilFail: function(res) {}
})
@ -128,7 +128,7 @@
}
},
goTest() {
uni.navigateTo({
uni.redirectTo({
url: '/pages/visit/testStudy?type=' + this.type
})
},

@ -29,7 +29,7 @@
if(this.iscall){
url = '/pages/bd/record?type=call'
}
uni.navigateTo({
uni.redirectTo({
url: url
})
}

@ -144,7 +144,7 @@
icon: 'none'
})
uni.removeStorageSync('formdata')
uni.navigateTo({
uni.redirectTo({
url:'/pages/visit/successform'
})
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

@ -0,0 +1 @@
.so-mask{position:fixed;top:0;bottom:0;right:0;left:0;background:rgba(0,0,0,0.5);z-index:998}.so-plate{box-sizing:border-box;position:absolute;bottom:0;width:100%;left:0;background:#fff;padding:25upx 25upx 0 25upx}.so-plate-head{display:-webkit-box;display:flex;-webkit-box-pack:justify;justify-content:space-between;-webkit-box-align:center;align-items:center}.so-plate-type{-webkit-box-flex:1;flex:1;display:block}.so-plate-type label{display:inline-block;min-height:32upx;font-size:26upx;margin-right:10upx}.so-plate-body{box-sizing:border-box;padding:30upx 0;display:-webkit-box;display:flex;-webkit-box-pack:justify;justify-content:space-between;-webkit-box-align:center;align-items:center}.so-plate-word{border:1upx solid #ccc;border-radius:10upx;height:0;margin:0 5upx;box-sizing:border-box;padding-bottom:calc(4.28571429%);width:calc(4.28571429%);position:relative}.so-plate-word.active{border-color:#007aff;box-shadow:0 0 15upx 0 #007aff}.so-plate-word text{position:absolute;top:50%;left:50%;-webkit-transform:translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%);font-weight:700;font-size:32upx}.so-plate-dot{width:15upx;height:15upx;background:#ccc;border-radius:50%;margin:0 5upx}.so-plate-keyboard{background:#eee;margin-left:-25upx;margin-right:-25upx;padding:20upx 25upx 10upx 25upx;box-sizing:border-box;-webkit-transition:all .3s;transition:all .3s}.so-plate-keyboard>view{display:-webkit-box;display:flex;flex-wrap:wrap;-webkit-box-pack:justify;justify-content:space-between}.so-plate-key{display:block;background:#fff;border-radius:10upx;box-shadow:0 0 8upx 0 #bbb;width:80upx;height:80upx;margin:5upx 0;font-size:32upx;text-align:center;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;position:relative}.so-plate-key.hover{background:#efefef}.so-plate-key.fill-block{width:80upx;height:80upx;background:none;box-shadow:none}.so-plate-btn{display:inline-block;background:#fff;border-radius:10upx;box-shadow:0 0 10upx 0 #bbb;font-size:28upx;text-align:center;margin:0 0 0 10upx}.so-plate-btn-group{display:-webkit-box;display:flex;-webkit-box-pack:justify;justify-content:space-between;background:#eee;margin-left:-25upx;margin-right:-25upx;box-sizing:border-box;padding:0 25upx 10upx 25upx}.so-plate-btn--cancel{margin:0}.so-plate-btn--submit{background:#5773f9;color:#fff}.so-plate-btn--delete{color:#fd6b6d}.animation-scale-up{-webkit-animation-duration:.2s;animation-duration:.2s;-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:scale-up;animation-name:scale-up}@-webkit-keyframes scale-up{0%{opacity:.8;-webkit-transform:scale(.8);transform:scale(.8)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes scale-up{0%{opacity:.8;-webkit-transform:scale(.8);transform:scale(.8)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}

@ -0,0 +1,154 @@
.so-mask {
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 998;
}
.so-plate {
box-sizing: border-box;
position: absolute;
bottom: 0;
width: 100%;
left: 0;
background: #fff;
padding: 25upx 25upx 0 25upx;
&-head {
display: flex;
justify-content: space-between;
align-items: center;
}
&-type {
flex:1;
display:block;
label {
display: inline-block;
min-height: 32upx;
font-size: 26upx;
margin-right: 10upx;
}
}
&-body {
box-sizing: border-box;
padding: 30upx 0;
display: flex;
justify-content: space-between;
align-items: center;
}
&-word {
border: 1upx solid #ccc;
border-radius: 10upx;
height: 0;
margin: 0 5upx;
box-sizing: border-box;
padding-bottom: calc((100% - 70upx) / 7);
width: calc((100% - 70upx) / 7);
position: relative;
&.active {
border-color: #007aff;
box-shadow: 0 0 15upx 0 #007aff;
}
text {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
font-weight: 700;
font-size: 32upx;
}
}
&-dot {
width: 15upx;
height: 15upx;
background: #ccc;
border-radius: 50%;
margin: 0 5upx;
}
&-keyboard {
background: #eee;
margin-left: -25upx;
margin-right: -25upx;
padding: 20upx 25upx 10upx 25upx;
box-sizing: border-box;
transition: all .3s;
&>view{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}
&-key {
display: block;
background: #fff;
border-radius: 10upx;
box-shadow: 0 0 8upx 0 #bbb;
width: 80upx;
height: 80upx;
margin: 5upx 0;
font-size: 32upx;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
position: relative;
&.hover {
background: #efefef;
}
&.fill-block {
width: 80upx;
height: 80upx;
background: none;
box-shadow: none;
}
}
&-btn {
display: inline-block;
background: #fff;
border-radius: 10upx;
box-shadow: 0 0 10upx 0 #bbb;
font-size: 28upx;
text-align: center;
margin:0 0 0 10upx;
padding:0 25upx;
&-group{
display: flex;
justify-content: space-between;
background: #eee;
margin-left: -25upx;
margin-right: -25upx;
box-sizing: border-box;
padding: 0 25upx 10upx 25upx;
}
&--cancel{
margin:0;
}
&--submit{
background:#5773f9;
color:#fff;
}
&--delete{
color:#fd6b6d;
}
}
}
.animation-scale-up {
animation-duration: .2s;
animation-timing-function: ease-out;
animation-fill-mode: both;
animation-name: scale-up
}
@keyframes scale-up {
0% {
opacity: .8;
transform: scale(.8)
}
100% {
opacity: 1;
transform: scale(1)
}
}

@ -0,0 +1,265 @@
/**
* @author minisola
* @version 20190814
*/
<template>
<view class="so-mask">
<view class="so-plate animation-scale-up">
<view class="so-plate-head">
<view class="so-plate-type">
<radio-group @change="typeChange">
<label>
<radio value="1" :checked="type===1" />
普通车牌
</label>
<label>
<radio value="2" :checked="type===2" />
新能源车牌
</label>
</radio-group>
</view>
</view>
<view class="so-plate-body">
<view class="so-plate-word" :class="{ active: currentInputIndex == 0 }" @tap="inputSwitch" data-index="0">
<text>{{ currentInputValue[0] }}</text>
</view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 1 }" @tap="inputSwitch" data-index="1">
<text>{{ currentInputValue[1] }}</text>
</view>
<view class="so-plate-dot"></view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 2 }" @tap="inputSwitch" data-index="2">
<text>{{ currentInputValue[2] }}</text>
</view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 3 }" @tap="inputSwitch" data-index="3">
<text>{{ currentInputValue[3] }}</text>
</view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 4 }" @tap="inputSwitch" data-index="4">
<text>{{ currentInputValue[4] }}</text>
</view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 5 }" @tap="inputSwitch" data-index="5">
<text>{{ currentInputValue[5] }}</text>
</view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 6 }" @tap="inputSwitch" data-index="6">
<text>{{ currentInputValue[6] }}</text>
</view>
<view class="so-plate-word" :class="{ active: currentInputIndex == 7 }" @tap="inputSwitch" v-if="type == 2" data-index="7">
<text>{{ currentInputValue[7] }}</text>
</view>
</view>
<view class="so-plate-foot">
<view class="so-plate-keyboard" :style="{height:keyboardHeight}">
<view id="keyboard">
<block v-if="inputType == 1">
<view hover-class="hover" class="so-plate-key" v-for="el of provinceText" :key="el" :data-value="el" @tap="chooseKey">{{ el }}</view>
</block>
<block v-if="inputType == 1">
<text class="so-plate-key fill-block"></text>
<text class="so-plate-key fill-block"></text>
</block>
<block v-if="inputType >= 3">
<view hover-class="hover" class="so-plate-key" v-for="el of numberText" :key="el" :data-value="el" @tap="chooseKey">{{ el }}</view>
</block>
<block v-if="inputType >= 2">
<view hover-class="hover" class="so-plate-key" v-for="el of wordText" :key="el" :data-value="el" @tap="chooseKey">{{ el }}</view>
</block>
<block v-if="inputType == 3">
<text v-for="el of fillBlock" :key="el.num" class="so-plate-key fill-block"></text>
</block>
<block v-if="inputType == 4">
<view hover-class="hover" class="so-plate-key" v-for="el of lastWordText" :key="el" :data-value="el" @tap="chooseKey">{{ el }}</view>
</block>
<text v-if="inputType == 4" class="so-plate-key fill-block"></text>
</view>
</view>
<view class="so-plate-btn-group">
<view>
<button class="so-plate-btn so-plate-btn--cancel" @tap="$emit('close')"></button>
</view>
<view>
<button class="so-plate-btn so-plate-btn--delete" @tap="deleteKey"></button>
<button class="so-plate-btn so-plate-btn--submit" @tap="exportPlate"></button>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'uni-plate-input',
data() {
return {
type: 1, //
currentInputIndex: 0, //
currentInputValue: ['', '', '', '', '', '', ''],
fillBlock:[{num:11},{num:12},{num:13},{num:14},{num:15},{num:16}], //:key
keyboardHeightInit:false,
keyboardHeight:'auto',
provinceText: [
'粤',
'京',
'冀',
'沪',
'津',
'晋',
'蒙',
'辽',
'吉',
'黑',
'苏',
'浙',
'皖',
'闽',
'赣',
'鲁',
'豫',
'鄂',
'湘',
'桂',
'琼',
'渝',
'川',
'贵',
'云',
'藏',
'陕',
'甘',
'青',
'宁',
'新'
],
numberText: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
wordText: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
lastWordText: ['港', '澳', '学', '领', '警']
};
},
props: {
plate: {
type: String
}
},
computed: {
//
inputType() {
switch (this.currentInputIndex) {
case 0:
return 1;
break;
case 1:
return 2;
break;
case 2:
return 3;
break;
case 3:
return 3;
break;
case 4:
return 3;
break;
case 5:
return 3;
break;
case 6:
return this.type==2 ? 3 :4 ;
break;
case 7:
return 4;
break;
default:
return 1;
break;
}
}
},
watch:{
currentInputIndex:function(n,o){
if(!this.keyboardHeightInit) return
this.$nextTick(()=>{
this.changeKeyboardHeight()
})
}
},
methods: {
//
typeChange(e) {
const {value} = e.detail;
this.type = parseInt(value)
this.currentInputIndex = 0
if(value==1){
this.currentInputValue = ['','','','','','','']
}else{
this.currentInputValue = ['','','','','','','','']
}
},
inputSwitch(e) {
const { index } = e.currentTarget.dataset;
this.currentInputIndex = parseInt(index);
},
chooseKey(e) {
const { value } = e.currentTarget.dataset;
this.$set(this.currentInputValue, this.currentInputIndex, value);
if(this.type==1 && this.currentInputIndex<6){
this.currentInputIndex++
}
if(this.type==2 && this.currentInputIndex<7){
this.currentInputIndex++
}
},
deleteKey(){
this.$set(this.currentInputValue,this.currentInputIndex,'')
if(this.currentInputIndex!=0) this.currentInputIndex--
},
exportPlate(){
const plate = this.currentInputValue.join('')
let err = false
if(this.type===1&&plate.length!=7){
err = true
}else if(this.type===2&&plate.length!=8){
err = true
}
if(err) return uni.showToast({
title:'请输入完整的车牌号码',
icon:'none'
})
this.$emit('export',plate)
},
changeKeyboardHeight(){
const that = this
const query = uni.createSelectorQuery().in(this);
query.select('#keyboard').boundingClientRect();
query.exec(function(res) {
if(res&&res[0]){
that.keyboardHeight = res[0].height + uni.upx2px(30) + 'px'
that.keyboardHeightInit = true
}
});
}
},
mounted() {
console.log(this.plate);
const plateKey = this.plate.split('')
if(plateKey.length===7){
this.type=1
}else if(plateKey.length===8){
this.type=2
}
if(plateKey.length===7 || plateKey.length===8){
this.currentInputValue = plateKey
this.currentInputIndex = plateKey.length-1
}
setTimeout(() => { //
this.$nextTick(()=>{
this.changeKeyboardHeight()
})
}, 500);
}
};
</script>
<style scoped lang="less">
@import './uni-plate-input';
</style>
Loading…
Cancel
Save