wjt
2024-06-21 44fe1eda9e4106ae105030fb548688812ba1d1e2
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
<template>
    <view class="page-box">
        <view class="box">
            <view class="form">
                <view class="form-item">
                    <view class="label">执法主题</view>
                    <view class="input">24年5月份消防突击检查</view>
                </view>
                <view class="form-item">
                    <view class="label">执法对象</view>
                    <view class="input">24年5月份消防突击检查</view>
                </view>
                <view class="form-item">
                    <view class="label">执法时间</view>
                    <view class="input">24年5月份消防突击检查</view>
                </view>
                <view class="form-item">
                    <view class="label">执法类型</view>
                    <view class="input">24年5月份消防突击检查</view>
                </view>
                <view class="form-item">
                    <view class="label">执法人员</view>
                    <view class="input">24年5月份消防突击检查</view>
                </view>
                <view class="form-item">
                    <view class="label">执法部门</view>
                    <view class="input">24年5月份消防突击检查</view>
                </view>
            </view>
        </view>
        <view class="box">
            <view class="form-input">
                <view class="form-input-item">
                    <view class="form-label require">执法结果</view>
                    <u-textarea placeholder="请输入..." count v-model="form.reasoon" maxlength="500"></u-textarea>
                </view>
                
                <view class="form-input-item">
                    <view class="form-label require">执法照片</view>
                    <view>
                        <view class="show-hint">可上传9张图,单张不得超过10m</view>
                    </view>
                    <view>
                        <uploadImage></uploadImage>
                    </view>
                </view>
            </view>
        </view>
        <view class="down">
            <view class="button">
                上报结果
            </view>
        </view>
    </view>
</template>
 
<script>
    import uploadImage from '@/policy/components/upload.vue'
    export default {
        components: {
            uploadImage
        },
        data() {
            return {
                form: {
                    reasoon: ''
                },
                fileList1: []
            }
        },
        methods: {
            // 删除图片
            deletePic(event) {
                this[`fileList${event.name}`].splice(event.index, 1)
            },
            // 新增图片
            async afterRead(event) {
                // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
                let lists = [].concat(event.file)
                let fileListLen = this[`fileList${event.name}`].length
                lists.map((item) => {
                    this[`fileList${event.name}`].push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })
                })
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url)
                    let item = this[`fileList${event.name}`][fileListLen]
                    this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
                        status: 'success',
                        message: '',
                        url: result
                    }))
                    fileListLen++
                }
            },
            uploadFilePromise(url) {
                return new Promise((resolve, reject) => {
                    let a = uni.uploadFile({
                        url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
                        filePath: url,
                        name: 'file',
                        formData: {
                            user: 'test'
                        },
                        success: (res) => {
                            setTimeout(() => {
                                resolve(res.data.data)
                            }, 1000)
                        }
                    });
                })
            },
            
        }
    }
</script>
<style>
    page {
        background-color: #F4F4F4;
    }
</style>
<style lang="scss" scoped>
    @import "./reportDetails.scss";
</style>