叶松
2023-11-21 6eaaba4f97028d581df3e019a7705d60b398c26e
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<template>
    <view class="check_add_index">
        <u-form
            ref="form"
            :model="formCheck"
            :rules="rulesCkeck"
            labelWidth="auto"
            labelPosition="left">
            <u-form-item
                    label="检查名称"
                    prop="inspectName"
                    borderBottom>
                <u-input
                    v-model="formCheck.inspectName"
                    placeholder="请输入检查名称"
                    border="none">
                </u-input>
            </u-form-item>
            <u-form-item
                    label="整改人"
                    prop="userIdValue"
                    borderBottom
                    @click="changeUser()">
                <u-input
                    v-model="formCheck.userIdValue"
                    placeholder="请选择整改人"
                    disabled
                    disabledColor="#FFFFFF"
                    border="none">
                </u-input>
                <u-icon
                    slot="right"
                    name="arrow-right">
                </u-icon>
            </u-form-item>
            <view class="items_tyle">
                <u-form-item
                    label="检查情况"
                    prop="inspectContent"
                    borderBottom>
                    <u--textarea v-model="formCheck.inspectContent" placeholder="请输入问题信息" height="100"></u--textarea>
                </u-form-item>
            </view>
            <view style="overflow: auto;width: 100%;background-color: #FFFFFF;" class="upload_items">
                <u-form-item>
                    <u-upload
                        :fileList="formCheck.imageList"
                        @afterRead="afterRead"
                        @delete="deleteImage"
                        name="66"
                        :previewFullImage="true"
                        :maxCount="6"
                        width="150"
                        height="150">
                        <image src="https://szpipe.thhy-tj.com/group1/M00/00/02/bx5d1GSihuWAA-kBAAAICqDtUn8566.png" mode="widthFix" style="width:64px;height: 100px;display: flex;justify-content: center;"></image>
                        <view style="text-align: center;font-size: 16px;color: #666666;">上传照片</view>
                    </u-upload>
                </u-form-item>
            </view>
        </u-form>
        <view class="submit_bnt">
            <u-button type="primary" color="#1976FF" text="提交" @click="submitInsertForm()"></u-button>
        </view>
        <u-picker 
            :show="showUser" 
            :columns="userColumns" 
            keyName="realName"
            @cancel="showUser = false"
            @confirm="selectCompany">
        </u-picker>
    </view>
</template>
 
<script>
    import { throttle } from '../../plugins/public.js';
    import { basrUrl } from '@/api/http';
    export default{
        data(){
            return{
                showUser: false,//整改人弹框显隐
                userColumns: [],//所有整改人
                formCheck:{
                    imageList:[],//上传图片
                    userId:'',//整改人
                },
                rulesCkeck: {
                    inspectName: [{
                        required: true,
                        message: '请输入姓名',
                        trigger: 'blur'
                    }],
                }
            }
        },
        onLoad(option) {
            console.log(option)
            this.getUsersData()
        },
        methods:{
            // 获取整改人信息
            getUsersData() {
                let arrUser = []
                this.$api.system.getAllUsersList({userType: 2}).then(res=>{
                    if(res.statusMsg === 'ok'){
                        res.data.list.map(item=>{
                            arrUser.push({
                                realName:item.realName,
                                userId:item.userId
                            })
                        })
                    }else{
                        uni.$u.toast(res.statusMsg);
                    }
                })
                this.userColumns = [arrUser]
            },
            //提交按钮
            submitInsertForm: throttle(function() {
                this.$refs.form.validate().then((valid) => {
                    if(valid) {
                        const params = Object.assign({}, this.formCheck);
                        params.files = this.formCheck.imageList.map(item=>{
                            return item.data
                        });
                        params.isType = 1;
                        delete params.userIdValue;
                        delete params.imageList;
                        this.$api.reboSystem.insertCheck(params).then((res) => {
                            if(res.success) {
                                uni.$u.toast("提交成功!");
                                uni.redirectTo({
                                    url: './checkSafe'
                                });
                            } else {
                                uni.$u.toast(res.statusMsg);
                            }
                        })
                    }
                })
            }, 3000),
            // 打开整改人选择
             changeUser() {
                 this.showUser = true;
                 this.$set(this.formCheck, 'userId', '');
                 this.$set(this.formCheck, 'userIdValue','');
             },
            // 确认选择整改人
            selectCompany({ value }) {
                 this.$set(this.formCheck, 'userId', value[0].userId);
                 this.$set(this.formCheck, 'userIdValue', value[0].realName);
                 this.showUser = false;
            },
            // 读取图片后
            afterRead(event) {
                this.formCheck.imageList.push({
                    status: 'loading',
                    message: '上传中',
                })
                uni.uploadFile({
                    url: `${basrUrl}/file/file/upload`,
                    fileType: event.file.type,
                    filePath: event.file.url,
                    name: 'file',
                    success: (res) => {
                        const data = JSON.parse(res.data);
                        this.$set(this.formCheck.imageList, this.formCheck.imageList.length - 1, {
                            id: this.formCheck.imageList.length + 1,
                            status: 'success',
                            message: '',
                            data: data.data,
                            url: `https://szpipe.thhy-tj.com/${data.data}`
                        })
                    },
                    fail: (error) => {
                        uni.$u.toast('上传失败!');
                    }
                })
            },
            // 删除图片
            deleteImage(event) {
                this.$nextTick(() => {
                    this.formCheck.imageList.splice(event.index, 1);
                })
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    .check_add_index{
        background-color: #F6F6F6;
        padding: 0 15px;
        position: relative;
        height: 100vh;
        overflow: hidden;
    }
    .submit_bnt {
        position: absolute;
        bottom: 5%;
        width: calc(100% - 30px);
    }
    
    
    ::v-deep .u-input__content__field-wrapper__field {
        text-align: right !important;
    }
    ::v-deep .u-form-item{
        margin: 15px 0;
        padding: 0 10px;
        background-color: #FFFFFF;
        line-height: 40px;
        border-radius: 4px;
    }
    ::v-deep .u-upload{
        flex: none !important;
        justify-content: center;
        align-items: center;
    }
    ::v-deep .u-textarea{
        background-color: #EFEFEF !important;
        color: #999999 !important;
    }
    
</style>
<style scoped>
    .items_tyle /deep/.u-form-item__body{
        flex-direction: column !important;
    }
    .upload_items /deep/.u-upload__wrap{
        flex-wrap: nowrap;
        align-items: center;
    }
</style>