k94314517
2024-04-09 02bc3bfe47e3d5311a0bb041c94e70a34b1ca73c
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<template>
    <view class="box">
        <view class="box_list">
            <u--form
                labelPosition="top"
                :model="model"
                :rules="rules"
                labelWidth="160"
                ref="uForm"
            >
                <u-form-item
                    label="姓名:"
                    prop="name"
                    borderBottom
                >
                    <u--input v-model="model.name" border="none" placeholder="请输入"></u--input>
                </u-form-item>
                <u-form-item
                    label="身份证号:"
                    prop="idCard"
                    borderBottom
                >
                    <u--input v-model="model.idCard" maxlength="18" border="none" placeholder="请输入"></u--input>
                </u-form-item>
                <u-form-item
                    label="派遣单位:"
                    prop="pqId"
                    borderBottom
                    @click="show = true"
                >
                    <u--input
                        v-model="model.pqName"
                        disabled
                        disabledColor="#ffffff"
                        placeholder="请选择"
                        border="none"
                    ></u--input>
                    <u-icon
                        slot="right"
                        name="arrow-right"
                    ></u-icon>
                </u-form-item>
                <u-form-item
                    label="所属工种:"
                    prop="gzId"
                    borderBottom
                    @click="show1 = true"
                >
                    <u--input
                        v-model="model.gzName"
                        disabled
                        disabledColor="#ffffff"
                        placeholder="请选择"
                        border="none"
                    ></u--input>
                    <u-icon
                        slot="right"
                        name="arrow-right"
                    ></u-icon>
                </u-form-item>
            </u--form>
        </view>
        <view class="box_footer">
            <u-button type="primary" shape="circle" color="#437CB3" text="确认添加" @click="submit"></u-button>
        </view>
        <!-- 派遣单位 -->
        <u-picker :show="show" :columns="columns" confirmColor="#437CB3" keyName="label" @cancel="show = false" @confirm="confirm"></u-picker>
        <!-- 工种 -->
        <u-picker :show="show1" :columns="columns1" confirmColor="#437CB3" keyName="label" @cancel="show1 = false" @confirm="confirm1"></u-picker>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                show: false,
                show1: false,
                solutionId: null,
                columns: [],
                columns1: [],
                duSolutionId: '',
                model: {
                    name: '',
                    idCard: '',
                    gzId: '',
                    gzName: '',
                    pqId: '',
                    pqName: ''
                },
                rules: {
                    'name': {
                        type: 'string',
                        required: true,
                        message: '请填写姓名',
                        trigger: ['blur', 'change']
                    },
                    'idCard': {
                        type: 'string',
                        required: true,
                        message: '请填写身份证号',
                        trigger: ['blur', 'change']
                    }
                }
            };
        },
        onLoad(options) {
            this.solutionId = options.solutionId
            this.getDispatchingUnit()
        },
        methods: {
            // 派遣单位
            getDispatchingUnit() {
                this.$u.api.findListByDTO({
                    solutionId: this.solutionId
                }).then(res => {
                    if (res.code === 200) {
                        let arr = res.data.map(item => {
                            return {
                                label: item.name,
                                duSolutionId: item.duSolutionId,
                                id: item.id
                            }
                        })
                        this.columns.push(arr)
                    }
                })
            },
            // 工种
            getGZ() {
                this.$u.api.worktypeFindListByDTO({
                    id: this.duSolutionId,
                    queryType: 1
                }).then(res => {
                    if (res.code === 200) {
                        let arr = res.data.map(item => {
                            return {
                                label: item.name,
                                id: item.id
                            }
                        })
                        this.columns1 = [arr]
                    }
                })
            },
            confirm(e) {
                this.model.pqId = e.value[0].id
                this.model.pqName = e.value[0].label
                this.duSolutionId = e.value[0].duSolutionId
                this.model.gzId = ''
                this.model.gzName = ''
                this.getGZ()
                this.show = false
            },
            confirm1(e) {
                this.model.gzId = e.value[0].id
                this.model.gzName = e.value[0].label
                this.show1 = false
            },
            submit() {
                this.$refs.uForm.validate().then(res => {
                    uni.$emit('add', { model: this.model })
                    uni.navigateBack({ delta: 1 });
                }).catch(errors => {
                    
                })
            }
        }
    }
</script>
<style>
    page {
        background-color: #f7f7f7;
    }
</style>
<style lang="scss" scoped>
    .box {
        width: 100vw;
        height: 100vh;
        padding: 20rpx 30rpx;
        box-sizing: border-box;
        .box_list {
            width: 100%;
            height: calc(100vh - 158rpx - env(safe-area-inset-bottom));
            background: #FFFFFF;
            border-radius: 16rpx;
            padding: 32rpx 30rpx;
            box-sizing: border-box;
        }
        .box_footer {
            width: 100%;
            margin-top: 40rpx;
            height: 88rpx;
        }
    }
</style>