wjt
2024-07-29 2ffea51205b7eb94cf3fb7221aede7ff66669fc1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<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>