zhouwenxuan
2023-07-27 2cb26124675883fa1e2742ae7899c9fc791ed6a2
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<template>
    <view>
        <!-- 自定义导航栏 -->
        <view class="navBarBox">
            <!-- 状态栏占位 -->
            <view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
            <!-- 真正的导航栏内容 -->
            <view style="display: flex; flex-direction: column;">
                <view class="navBar">
                    <u-icon name="arrow-left" color="black" size="17" @click="goBack" />
                    <view class="barText">信息详情</view>
                </view>
            </view>
        </view>
        <!-- 页面内容 -->
        <view class="detailCard">
            <text style="font-size: 18px;"><b>标题:</b>{{detailData.title}}</text>
            <text class="textTop"><b>类别:</b>{{detailData.disaster}}</text>
            <view style="display: flex;align-items: center;" class="textTop">
                <text><b>级别:</b></text>
                <u-tag 
                    :color="detailData.warningLevel === 3 ? 'rgb(255, 244, 88)' :detailData.warningLevel === 2 ? 'orange':detailData.warningLevel === 1 ?'red':'blue'"
                    :text="detailData.warningLevel === 3 ? '黄色' : detailData.warningLevel === 2 ? '橙色': detailData.warningLevel === 1 ?'红色':'蓝色'" 
                    :bg-color="detailData.warningLevel === 3 ? 'rgb(254, 255, 230)' :detailData.warningLevel === 2 ? 'rgb(255, 210, 179)':detailData.warningLevel === 1 ?'rgb(255, 128, 128)':'rgb(121, 150, 255)'"
                    border-color="white">
                </u-tag>
            </view>
            <text class="textTop"><b>发布单位:</b>{{detailData.publishingUnit}}</text>
            <text class="textTop"><b>短信内容:</b><i style="background-color: rgb(240, 248, 255);">{{detailData.content}}发布单位:{{detailData.publishingUnit}}</i></text>
            <view style="display: flex;">
                <text class="textTop" style="width: 76px;" ><b>附件内容:</b></text>
                <!-- <view class="attache" v-if="isAllImg == 'no'">
                    <view v-for="(item, index) in detailData.attachments" :key="index" >
                            <view  style="display: flex;margin-top: 10px;" v-if="item.suffix == 'jpg'|| item.suffix =='jpeg' || item.suffix =='png'"> 
                                <image  @click="previewSqs(item,index)" :src="item.attachment" style="width: 100rpx; height: 100rpx;margin-left: 5rpx;border: 3px solid #ccc;margin-right: 3px;"></image>
                            </view>
                            <view style="display: flex;margin-top: 10px;" @click="openFile(item)" v-else>
                                <u-icon name="attach" color="#2979ff" size="20"></u-icon> {{item.attachementName}}
                            </view>
                    </view>
                </view>
                
                <view class="attache_img" v-else>
                    <view v-for="(item, index) in detailData.attachments" :key="index" >
                            <view  style="display: flex;margin-top: 10px;" v-if="item.suffix == 'jpg'|| item.suffix =='jpeg' || item.suffix =='png'"> 
                                <image  @click="previewSqs(item,index)" :src="item.attachment" style="width: 100rpx; height: 100rpx;margin-left: 5rpx;border: 3px solid #ccc;margin-right: 3px;"></image>
                            </view>
                            <view style="display: flex;margin-top: 10px;" @click="openFile(item)" v-else>
                                <u-icon name="attach" color="#2979ff" size="20"></u-icon> {{item.attachementName}}
                            </view>
                    </view>
                </view> -->
                
<!--                 <view style="width: 100%; height: 100px;">
                    <iframe :src="" width="100%" height="100%"> </iframe>
                </view> -->
                
            </view>
            <text class="textTop" v-if="detailData.role == 'leader'"><b>信息提交人:</b>{{detailData.infoSubmitterRealName}}</text>
            <view class="textTop" v-if="detailData.role == 'leader'">
                <text ><b>审核状态:</b></text>
                <text v-if="detailData.reviewStatus == 1" class="responseStatus"
                    style='color: red;'>待审核</text>
                <text v-else-if="detailData.reviewStatus == 2" class="responseStatus"
                    style='color: rgb(17, 204, 33);'>审核通过</text>
                <text v-else class="responseStatus"
                    style='color: rgb(153, 148, 143);'>已驳回</text>
            </view>
            <view class="textTop" v-else-if="detailData.role == 'infoPeople'">
                <text ><b>审核状态:</b></text>
                <text v-if="detailData.reviewStatus == 1" class="responseStatus"
                    style='color: red;'>待审核</text>
                <text v-else-if="detailData.reviewStatus == 2" class="responseStatus"
                    style='color: rgb(17, 204, 33);'>审核通过</text>
                <text v-else class="responseStatus"
                    style='color: rgb(153, 148, 143);'>已驳回</text>
            </view>
            <view class="textTop" v-else>
                <text ><b>响应状态:</b></text>
                <text v-if="detailData.responseStatus == 1" class="responseStatus"
                    style='background-color:rgb(247, 108, 125);color: white;'>待叫应</text>
                <text v-else-if="detailData.responseStatus == 2" class="responseStatus"
                    style='background-color:limegreen'>已叫应</text>
                <text v-else class="responseStatus"
                    style='background-color:rgb(247, 108, 125); color: white;'>超时未叫应</text>
            </view>
            <view v-if="detailData.role == 'leader' && detailData.reviewStatus == 1" class="btn">
                <u-button 
                    style="background-color:rgb(6, 202, 23);color: white;width: 180px;"
                    @click="approved"
                >审核通过</u-button>
                <u-button 
                    style="background-color:rgb(247, 108, 125);color: white;width: 180px;"
                    @click="reject"
                >审核驳回</u-button>
            </view>
            <view v-if="detailData.role == 'infoPeople' && detailData.reviewStatus == 2" class="btn">
                <u-button 
                    style="background-color:rgb(6, 202, 23);color: white;width: 180px;"
                    @click="infoSend"
                >确认发布</u-button>
            </view>
        <!--     //村级显示 -->
        </view>
        <view class="measures">
            <u-button class="resBtn" type="primary" @click="goMeasures">响应措施反馈</u-button>
        </view>
    </view>
</template>
 
<script>
    import VUE_APP_BASE_URL from '../../../common/constant.js'
    import { submit } from '../../../api/examine.js'
    import { publishInfo } from '../../../api/information.js'
    export default {
        data() {
            return {
                // 状态栏高度
                statusBarHeight: 0,
                key: 1,
                isAllImg: '',
                detailData: {
                    id: null,
                    warnInfoId: null,
                    disasterType: null,
                    warningLevel: null,
                    title: "",
                    content: "",
                    publishingUnit: "",
                    attachments: [],
                    responseStatus: null
                },
                submitData: {
                    id: null,
                    reviewStatus: null
                }
            }
        },
         onLoad:function(options){
             //获取手机状态栏高度
            this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
            let test = options.data && JSON.parse(decodeURIComponent(options.data));
            this.detailData = test;
            
            if(this.detailData.role == 'leader' || this.detailData.role == 'infoPeople' ) {
                this.detailData.attachments = this.detailData.attachment;
                if (this.detailData.attachments){
                    this.detailData.attachments.forEach((item,index) => {
                        item.attachementName = this.detailData.attachment[index].attachmentName;
                    })
                }
            }
            if (this.detailData.attachments){
                this.detailData.attachments.forEach((item,index) => {
                    item.suffix = item.attachementName.substring(item.attachementName.lastIndexOf(".") + 1);
                    if(item.suffix == 'jpg'|| item.suffix =='jpeg' || item.suffix =='png' ){
                        if(this.detailData.role == 'leader' || this.detailData.role == 'infoPeople' ){
                          item.attachment = VUE_APP_BASE_URL + item.attachment;
                        }else {
                          item.attachment = VUE_APP_BASE_URL + item.attachement;
                        }
                        
                    }else {
                        this.isAllImg = 'no';
                    }
                })
            }
            console.log("this.isAllImg",this.isAllImg)
            console.log("detailData",this.detailData)
            this.detailData.disaster = test.disasterType == 1 ? '地震': test.disasterType == 2 ? '洪涝' : test.disasterType == 3 ? '气象' : test.disasterType == 4 ? '泥石流': test.disasterType == 5 ? '水旱': '森林草原火灾';
        },
        methods: {
            goBack() {
                uni.navigateBack({
                    url:'./notice/notice'
                });
            },
            goMeasures() {
                uni.navigateTo({
                  url: `/pages/tabBar/notice/measures?data=` + encodeURIComponent("2")
                })
            },
            //审核通过
            approved() {
                this.submitData.id = this.detailData.id;
                this.submitData.reviewStatus = 2;
                submit(this.submitData).then(res => {
                    if(res.code==100) {
                        this.goBack();
                    }
                });
            },
            //审核驳回
            reject() {
                this.submitData.id = this.detailData.id;
                this.submitData.reviewStatus = 3;
                submit(this.submitData).then(res => {
                    if(res.code==100) {
                        this.goBack();
                    }
                })
            },
            //信息发布
            infoSend() {
                publishInfo({id: this.detailData.id}).then(res => {
                    if(res.code==100) {
                        this.goBack();
                    }
                })
                console.log("信息发布")
            },
            //预览图片
            previewSqs(item,index) {
                
                let imgs = [];
                for (let i = 0; i < this.detailData.attachments.length; i++) {
                    imgs.push(this.detailData.attachments[i].attachment)
                }
                console.log("预览",imgs)
                uni.previewImage({
                    urls: imgs,
                    current: index,
                    indicator: 'number',
                    loop: true
                })
            },
            //预览文件
            openFile(item) {
                let fileUrl = '';
                console.log("iiii",item)
                if(this.detailData.role == 'leader' || this.detailData.role == 'infoPeople' ){
                  fileUrl = VUE_APP_BASE_URL + item.attachment;
                }else {
                  fileUrl = VUE_APP_BASE_URL + item.attachement;
                }
                console.log("urlllllllll",fileUrl)
                uni.downloadFile({
                    url: fileUrl,
                    header: {},
                    success:function(res){
                        console.log("下载res",res);
                        var filePath = res.tempFilePath;
                        const sidx = filePath.lastIndexOf('(');
                        const eidx = filePath.lastIndexOf(')');
                        //  用于处理文档打开问题(ps:第一次打开 第二次无法打开问题)
                        if (sidx > -1 && eidx > -1) {
                            const restr = filePath.substr(sidx, eidx - sidx + 1);
                            filePath = filePath.replace(restr, '');
                        }
                        // plus.runtime.openFile(filePath)
                        uni.openDocument({
                          filePath: filePath,
                          success:function(){
                            console.log('成功')
                        },
                      fail:function(){
                        uni.showToast({
                              icon: 'none',
                              title: '暂不支持此类型',
                              duration: 2000
                            })
                        }
                    })
                }
            })
          }
        }
    }
</script>
 
<style lang="scss" scoped>
a{
    text-decoration: none;
}
.navBarBox .navBar {
  background-color:#fff;
  height: 50px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
}
.barText{
  /* margin-left: 20px; */
  text-align: center;
  width: 85%;
  font-size: 16px;
  /* text-align: center; */
  font-weight: 600;
}
.navBarBox .navBar .logo {
    width: 82rpx;
    height: 82rpx;
    margin-right: 10rpx;
}
.textTop{
    margin-top: 20px;
    font-size: 15px;
    
}
.attache{
    margin-top: 10px;
    flex: 1; 
    display: flex;
    flex-direction: column;
}
.attache_img {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
}
.responseStatus{
    padding:5px;
    color:#2a2a2a;
    border-radius: 5px;
}
.divider{
    height: 1px;
    width: 93%;
    background-color: lightgray;
    margin-left: 15px;
}
.detailCard{
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 3px 12px rgba(0,0,0,0.05);
    margin: 12px 12px 20px;
    border-radius: 5px;
    padding: 30px 12px;
}
.btn{
    margin-top: 80px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
}
.measures{
    margin-top: 50px 12px 0;
    padding: 0 12px;
    
    .resBtn{
        border-radius: 5px;
        box-shadow: 0 3px 12px rgba(33,148,239,0.4);
    }
}
 
</style>