<template>
|
<u-popup mode="bottm" :show="show" :safeAreaInsetBottom="false">
|
<view class="picker-view-box">
|
<view class="options">
|
<view class="button" @click="cancel" size="mini">取消</view>
|
<view class="button entery" @click="entery" color="#1171E0" size="mini">确定</view>
|
</view>
|
<view class="set-flex">
|
<u-search v-model="companyName" @search="companyList" @clear="clearContent" @confirm="companyList" @custom="companyList()"></u-search>
|
<text @click="addContent">新增</text>
|
</view>
|
<view>
|
<picker-view immediate-change :value="value" @change="bindChange" class="picker-view">
|
<picker-view-column>
|
<view class="text-center" v-for="(item,index) in columns" :key="index">{{item[keyName]}}</view>
|
</picker-view-column>
|
</picker-view>
|
</view>
|
</view>
|
</u-popup>
|
</template>
|
|
<script>
|
import { companyList } from '@/api/policy.js'
|
export default {
|
props: {
|
keyName: {
|
type: String,
|
default: ''
|
}
|
},
|
data() {
|
return {
|
columns: [],
|
show: false,
|
companyName: "",
|
index: 0,
|
value: []
|
}
|
},
|
mounted() {
|
this.companyList()
|
},
|
methods: {
|
clearContent() {
|
this.companyName = ""
|
this.companyList()
|
},
|
cancel() {
|
this.show = false
|
},
|
open() {
|
this.show = true
|
},
|
bindChange(e) {
|
this.index = e.detail.value[0]
|
},
|
companyList() {
|
return companyList({companyName: this.companyName, companyStatus: 0, checkStatus: 2}).then(val => {
|
if(val.data.code == 200){
|
if(!val.data.rows.length || !val.data.rows){
|
// uni.showToast({
|
// title: '没有符合的数据,请检查输入的执法对象',
|
// icon: 'none',
|
// duration: 3000
|
// })
|
this.columns = val.data.rows || []
|
} else {
|
this.columns = val.data.rows
|
}
|
|
}
|
})
|
},
|
entery() {
|
const info = this.columns[this.index]
|
this.$emit('confirm', info)
|
this.show = false
|
},
|
async addContent() {
|
await this.companyList()
|
// console.log(this.columns.length)
|
if(this.columns.length) {
|
|
} else {
|
this.$emit('setCompany', this.companyName)
|
this.show = false
|
}
|
}
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.picker-view-box{
|
position: fixed;
|
z-index: 120000;
|
background-color: white;
|
height: 600rpx;
|
padding: 40rpx 32rpx 0;
|
bottom: 0;
|
width: 100%;
|
box-sizing: border-box;
|
border-radius: 20rpx 20rpx 0 0;
|
}
|
.options{
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 40rpx;
|
.button{
|
padding: 10rpx 20rpx;
|
border-radius: 10rpx;
|
font-size: 28rpx;
|
}
|
.entery{
|
background-color: $main-color;
|
color: white;
|
|
}
|
}
|
.text-center{
|
text-align: center;
|
line-height: 34px;
|
}
|
.picker-view {
|
width: 100%;
|
height: 500rpx;
|
margin-top: 20rpx;
|
}
|
.set-flex{
|
display: flex;
|
justify-content: flex-start;
|
align-items: center;
|
text{
|
display: inline-block;
|
background-color: $main-color;
|
color: white;
|
border-radius: 5px;
|
padding: 5px 15px;
|
margin-left: 20rpx;
|
font-size: 24rpx;
|
}
|
}
|
</style>
|