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
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
<template>
    <view class="page-box">
        <u-form label-width="80" ref="uForm"  labelPosition="top" :model="form" :rules="rules">
            <u-form-item label="访问企业" prop="companyName">
                <u-input placeholder="请输入" disabled v-model="form.companyName"></u-input>
            </u-form-item>
            <u-form-item label="来访时间" prop="comeTime">
                <u-input placeholder="请输入" disabled v-model="form.comeTime"></u-input>
            </u-form-item>
            <u-form-item label="来访单位" @click="selectValue" prop="comeDeptName">
                <u-input placeholder="请输入" readonly :value="form.comeDeptName"></u-input>
            </u-form-item>
            <u-form-item label="来访人员" prop="comeUser">
                <u-input placeholder="请输入" v-model="form.comeUser"></u-input>
            </u-form-item>
            <u-form-item label="来访事项" prop="comeContent">
                <u-textarea  placeholder="请输入" v-model="form.comeContent"></u-textarea>
            </u-form-item>
            <u-form-item label="随行人数" prop="userNum">
                <u-input placeholder="请输入" v-model="form.userNum" type="number"></u-input>
            </u-form-item>
            <u-form-item label="备注" prop="remark">
                <u-textarea  placeholder="请输入" v-model="form.remark"></u-textarea>
            </u-form-item>
        </u-form>
        <view class="down-options-button">
            <view class="options">
                <u-button type="primary" @click="addLog">提交</u-button>
            </view>
            <view class="options">
                <u-button type="info " @click="reset">重置</u-button>
            </view>
        </view>
        <u-picker :show="show" @close="show = false" @confirm="confirm" @cancel="show = false" keyName="deptName" :columns="columns"></u-picker>
    </view>
</template>
 
<script>
    import { companyList } from '@/api/policy.js'
    import { deptList,addLog } from '@/api/index.js'
    export default {
        data() {
            return {
                code: '',
                form: {
                    companyName: "",
                    comeTime: "",
                    comeDeptName: ""
                },
                show: false,
                columns: [],
                rules:{
                    'companyName': {
                        required: true,
                        message: '请选择访问企业',
                        trigger: ['blur', 'change']
                    },
                    comeTime: {
                        required: true,
                        message: '请选择来访时间',
                        trigger: ['blur', 'change']
                    },
                    comeDeptName: {
                        required: true,
                        message: '请选择来访单位',
                        trigger: ['blur', 'change']
                    },
                    comeUser: {
                        required: true,
                        message: '请输入来访人员',
                        trigger: ['blur', 'change']
                    },
                    comeContent: {
                        required: true,
                        message: '请输入来访事项',
                        trigger: ['blur', 'change']
                    }
                }
            }
        },
        onLoad(options) {
            this.code = options.value
            this.companyList()
            this.deptList()
        },
        methods: {
            reset() {
                const { companyName, comeTime, companyId, companyUser, companyPhone } = this.form
                this.form = {
                    companyName: companyName,
                    companyId: companyId,
                    comeTime: comeTime,
                    companyUser: companyUser,
                    companyPhone: companyPhone,
                    comeDeptName: ""
                }
            },
            addLog() {
                this.$refs.uForm.validate().then(val => {
                    addLog(this.form).then(val => {
                        // console.log(val)
                        if(val.data.code == 200) {
                            // uni.showToast({
                            //     title: '登记成功',
                            //     icon: 'none',
                            //     duration: 5000
                            // })
                            // setTimeout(() => {
                            //     uni.navigateBack()
                            // }, 500)
                            uni.showModal({
                                title: '提示',
                                content: '登记成功',
                                showCancel: false,
                                success: val => {
                                    if(val.confirm) {
                                        uni.navigateBack()
                                    }
                                }
                            })
                        }
                    })
                }).catch(err => {
                    console.log(err)
                })
            
            },
            confirm(e) {
                this.form.comeDeptName = e.value[0].deptName
                this.form.comeDeptId = e.value[0].deptId
                this.show = false
            },
            deptList(){
                deptList({parentId: 100}).then(val => {
                    // console.log(val.data.data)
                    this.columns = [val.data.data]
                })
            },
            companyList() {
                companyList({companyCode: this.code}).then(val => {
                    if(val.data.rows.length) {
                        const details = val.data.rows[0]
                        this.form.companyName = details.companyName
                        this.form.companyId = details.companyId
                        this.form.companyUser = details.companyUser
                        this.form.companyPhone = details.companyPhone
                        // this.form.
                        this.form.comeTime = this.$u.timeFormat(new Date(), 'yyyy-mm-dd')
                    }
                })
            },
            selectValue() {
                this.show = true
            }
        }
    }
</script>
<style>
    page{
        padding: 20rpx;
        box-sizing: border-box;
    }
</style>
<style lang="scss" scoped>
    .page-box{
        padding-bottom: 220rpx;
    }
.down-options-button{
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0;
    width:  100%;
    background-color: white;
    padding: 20rpx 20rpx 40rpx;
    box-sizing: border-box;
    left: 0;
    .options{
        width: 48%;
    }
}
</style>