Commit 4ceee9cf by 张权

0704需求开发

1 parent 28da898e
<template>
<div>
<el-input @blur.stop="formatPhone" type="textarea" v-model="phone" :placeholder="placeholder"></el-input>
<span v-if="isTip" class="approval-tip" style="margin-left:0;">{{ tip }}</span>
<div>
<div :class="['tel-item', !item.valid ? 'valid-tel' : receiveType == 1 ? 'realTel' : 'realNum']" v-for="(item, index) in phoneList" :key="index">
{{ item.tel }}
<i style="cursor:pointer" class="el-icon-close" @click="delPhone(item.tel)"></i>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'phone-area',
model: {
prop: 'newList',
event: 'changePhoneList'
},
props: {
receiveType: {
type: String,
require: true,
default: ''
},
placeholder: {
type: String,
default: ''
},
isTip: {
type: String,
default: ''
}
},
data() {
return {
phone: '',
phoneList: []
}
},
methods: {
delPhone(val) {
let phone = '\n' + this.phone + '\n'
phone = phone.replace(/[\n]/g, '\n\n')
phone = phone.replace(new RegExp('[\n]' + val + '[\n]', 'g'), '\n')
phone = phone.replace(/[\n]+/g, '\n')
phone = phone.replace(/^[\n]+/, '')
this.phone = phone
this.formatPhone()
},
formatPhone() {
let phoneList = this.phone.split('\n')
phoneList = [...new Set(phoneList)]
// let phoneList = this.phone.split(/[\n|\s|,|,]/)
let reg
if (this.receiveType == 1) {
reg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
} else {
reg = /^[0-9a-zA-Z]{6}$/
}
let arr = []
phoneList.forEach(item => {
arr.push({
tel: item,
valid: reg.test(item)
})
})
this.phoneList = arr.filter(item => item.tel)
this.$emit('changePhoneList', this.phoneList)
}
}
}
</script>
<style scope lang="scss">
.tel-item {
height: 26px;
display: inline-block;
padding: 0 8px;
line-height: 26px;
background: #fafbfe;
border-radius: 4px;
border: 1px solid #e8e8ea;
color: #666666;
text-align: center;
margin-right: 4px;
box-sizing: border-box;
}
.valid-tel {
background: #fff1f0;
border: 1px solid #ffa39e;
color: #ff4d4f;
}
.realTel {
width: 130px;
}
.realNum {
width: 90px;
}
</style>
...@@ -101,12 +101,13 @@ export default { ...@@ -101,12 +101,13 @@ export default {
} }
}, },
{ {
type: 'el-button', type: 'GLButton',
name: row => { name: row => {
return '生成二维码' return '生成二维码'
}, },
attrs: { attrs: {
type: 'text' type: 'text',
fn: '生成二维码'
}, },
listeners: { listeners: {
click: row => this.makeQrcode(row.scope) click: row => this.makeQrcode(row.scope)
...@@ -470,6 +471,9 @@ export default { ...@@ -470,6 +471,9 @@ export default {
width: 360px; width: 360px;
height: 36px; height: 36px;
} }
.el-input__icon {
line-height: 36px;
}
} }
img { img {
width: 160px; width: 160px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!