From f693c859cdaf607c2a146ef89a7a2ce0d9476d1a Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期五, 07 四月 2023 15:49:09 +0800
Subject: [PATCH] 修改首页

---
 miniprogram/pages/user/report/submitReport/index.ts |  203 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 155 insertions(+), 48 deletions(-)

diff --git a/miniprogram/pages/user/report/submitReport/index.ts b/miniprogram/pages/user/report/submitReport/index.ts
index 39cdb1e..5eb26a5 100644
--- a/miniprogram/pages/user/report/submitReport/index.ts
+++ b/miniprogram/pages/user/report/submitReport/index.ts
@@ -1,8 +1,13 @@
 // index.ts
 const submitReport = getApp()
 import Toast from '@vant/weapp/toast/toast';
+import { formatTime } from 'miniprogram/utils/util';
 Page({
     data: {
+        phoneDisab:true,
+        isInGroup:'',
+        remarks: '',
+        addFig:false,
         aaaform: {},
         capture: ['camera'],
         beforList: 'a',
@@ -19,7 +24,9 @@
         causeIndex: null,
         items: { name: '鏃ユ湡鏃堕棿閫夋嫨', value: 'dateTime' },
         mode: 'dateTime',
-        reportDetail: {},
+        reportDetail: {
+            causeId:''
+        },
         causeList: [],
         imagesFile: [],
         cardIdList: [],
@@ -31,6 +38,36 @@
             { sex: '濂�', id: 0 }
         ],
         sexId: 0
+    },
+    afterRadeDel(e){
+        console.log(e);
+        console.log(this.data.cardIdList);
+        let arr=this.data.cardIdList
+        arr.splice(e.detail.index,1)
+        this.setData({
+            cardIdList: arr
+        })
+    },
+    afterRadeDelFile(e){
+        let arr=this.data.fileImgList
+        arr.splice(e.detail.index,1)
+        this.setData({
+            fileImgList: arr
+        })
+    }, 
+    afterRadeDelTran(e){
+        let arr=this.data.transactionReceiptList
+        arr.splice(e.detail.index,1)
+        this.setData({
+            transactionReceiptList: arr
+        })
+    },
+    afterRadeDelOther(e){
+        let arr=this.data.otherList
+        arr.splice(e.detail.index,1)
+        this.setData({
+            otherList: arr
+        })
     },
     getrealName(e) {
         this.setData({
@@ -45,6 +82,11 @@
     getuserIdCard(e) {
         this.setData({
             userIdCard: e.detail
+        })
+    },
+    getuserPhone(e){
+        this.setData({
+            phone: e.detail
         })
     },
     getLocation(e) {
@@ -83,14 +125,16 @@
             formData: { user: 'test' },
             success(res) {
                 // 涓婁紶瀹屾垚闇�瑕佹洿鏂� fileList
-                const { fileImgList = [] } = that.data;
-                const { transactionReceiptList = [] } = that.data;
-                const { otherList = [] } = that.data;
-                const { cardIdList = [] } = that.data;
+                const { fileImgList = [] } = that.data;  //鍚堝悓
+                const { transactionReceiptList = [] } = that.data; // 浜ゆ槗鍑瘉
+                const { otherList = [] } = that.data; //鍏朵粬
+                const { cardIdList = [] } = that.data;  //韬唤璇�
                 let result = JSON.parse(res.data)
                 if (that.data.beforList == 'a') {
                     cardIdList.push({ ...file, url: result.data });
                     that.setData({ cardIdList });
+                    console.log(that.data.cardIdList);
+                    
                 } else if (that.data.beforList == 'b') {
                     fileImgList.push({ ...file, url: result.data });
                     that.setData({ fileImgList });
@@ -113,6 +157,8 @@
             causeIndex: e.detail.value
         })
         this.data.reportDetail.causeId = this.data.causeList[e.detail.value].id
+        console.log(e,this.data.causeIndex,this.data.reportDetail.causeId);
+        
     },
     uploadImage() {
         wx.chooseMedia({
@@ -147,7 +193,7 @@
                 }
             }
         })
-
+ 
     },
     //琚獥鏃堕棿
     onPickerChange(e) {
@@ -156,6 +202,8 @@
     subSex(e) {
     },
     bindPickerChangeSex(e) {
+        console.log(e);
+        
         this.setData({
             sexId: e.detail.value
         })
@@ -179,6 +227,8 @@
         })
     },
     pass() {
+        console.log(this.data.reportDetail.causeId);
+        
         if (this.data.realName == '') {
             Toast('璇疯緭鍏ュ鍚嶏紒');
             return
@@ -191,17 +241,20 @@
         } else if (this.data.workingLocation == '') {
             Toast('璇疯緭鍏ュ伐浣滃崟浣嶏紒');
             return
+        }else if (this.data.reportDetail.causeId == '') {
+            Toast('璇烽�夋嫨鎻忚堪锛�');
+            return
         } else if (this.data.amountInvolved == '') {
             Toast('璇疯緭鍏ュ彈鎹熼噾棰濓紒');
             return
         } else if (this.data.cardIdList.length != 2) {
             Toast('璇烽�夋嫨韬唤璇佺収鐗囷紒');
             return
-        }
+        } 
         if (this.data.fileImgList.length != 0 || this.data.transactionReceiptList.length != 0 || this.data.otherList.length != 0) {
-
+ 
         } else {
-            Toast('鐩稿叧鍚堝悓锛屼氦鏄撳嚟璇侊紝鍏朵粬;蹇呭~涓�椤癸紒');
+            Toast('鐩稿叧鍚堝悓銆佷氦鏄撳嚟璇併�佸叾浠�;蹇呭~涓�椤癸紒');
             return
         }
         this.data.materials = this.data.materials.substring(0, this.data.materials.length - 1);
@@ -215,10 +268,10 @@
         this.data.reportDetail.reportMaterials = this.data.materials
         this.data.reportDetail.userId = wx.getStorageSync('id')
         this.data.reportDetail.cheatTime = this.data.cheatTime
-        this.data.reportDetail.idCardMaterials = this.data.cardIdList.map(res => res.url).join(',')
-        this.data.reportDetail.contractMaterials = this.data.fileImgList.map(res => res.url).join(',')
-        this.data.reportDetail.transactionMaterials = this.data.transactionReceiptList.map(res => res.url).join(',')
-        this.data.reportDetail.elseMaterials = this.data.otherList.map(res => res.url).join(',')
+        this.data.reportDetail.idCardMaterials =this.data.cardIdList.length>0? this.data.cardIdList.map(res => res.url).join(','):null
+        this.data.reportDetail.contractMaterials =this.data.fileImgList.length>0? this.data.fileImgList.map(res => res.url).join(','):null
+        this.data.reportDetail.transactionMaterials =this.data.transactionReceiptList.length>0? this.data.transactionReceiptList.map(res => res.url).join(','):null
+        this.data.reportDetail.elseMaterials =this.data.otherList.length>0? this.data.otherList.map(res => res.url).join(','):null;;
         // if (  this.data.reportDetail.information==null||  this.data.reportDetail.reportDescription==null) {
         //     wx.showToast({
         //         icon: "none",
@@ -226,10 +279,11 @@
         //     })
         //     return
         // }
+      if (wx.getStorageSync('role')==1) {
         wx.request(
             {
-                url: submitReport.globalData.url + "/wx/user/addReport",
-                method: "POST",
+                url: submitReport.globalData.url + "/wx/user/policeAddReport",
+                method: this.data.addFig?"PUT":"POST",
                 data: this.data.reportDetail,
                 header: {
                     'token': wx.getStorageSync('token'),
@@ -240,11 +294,35 @@
                     })
                 }
             })
+      }else{
+        wx.request(
+            {
+                url: submitReport.globalData.url + "/wx/user/addReport",
+                method: this.data.addFig?"PUT":"POST",
+                data: this.data.reportDetail,
+                header: {
+                    'token': wx.getStorageSync('token'),
+                    'content-type': 'application/json'
+                }, success: (res) => {
+                    wx.reLaunch({
+                        url: '../../report/index'
+                    })
+                }
+            })
+      }
+      
     },
-    onLoad(e) {
+    onLoad:function(e) {
+        console.log(e);
         let that = this
+        let role = wx.getStorageSync('role')
+        if (role==1) {
+            that.setData({
+                phoneDisab :false
+            })
+        }
         let phone = wx.getStorageSync('phone')
-        this.setData({
+        that.setData({
             phone: phone
         })
         var date = new Date()
@@ -270,84 +348,113 @@
             secends = "0" + secends
         }
         this.data.cheatTime = date.getFullYear() + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + secends
-        this.loadData(e)
-        wx.request(
-            {
-                url: submitReport.globalData.url + "/cause/getVxCauseList?phone=" + that.data.phone,
-                method: "GET",
-                header: { 'token': wx.getStorageSync('token') },
-                success: (res) => {
-                    let causes = res.data.data
-                    console.log(that.data.aaaform);
-                    if (e.id) {
-                        causes.push({
-                            id: that.data.aaaform.causeId,
-                            name: that.data.aaaform.description
+        if (e.id ) {
+            this.loadData(e)
+        }else{
+            wx.request(
+                {
+                    url: submitReport.globalData.url + "/cause/getVxCauseList?phone=" + that.data.phone,
+                    method: "GET",
+                    header: { 'token': wx.getStorageSync('token') },
+                    success: (res) => {
+                        let causes = res.data.data
+                        console.log(that.data.aaaform);
+                        if (e.id) {
+                            causes.push({
+                                id: that.data.aaaform.causeId,
+                                name: that.data.aaaform.description
+                            })
+                            this.setData({                              
+                                causeIndex: causes.findIndex(i => i.id == that.data.aaaform.causeId)
+                            })
+                        }                       
+                        this.setData({
+                            causeList: causes,
+                            // causeIndex: causes.findIndex(i => i.id == that.data.aaaform.causeId)
                         })
+                        console.log(this.data.causeList,this.data.causeIndex);
+                        
                     }
-                    this.setData({
-                        causeList: causes,
-                        causeIndex: causes.findIndex(i => i.id == that.data.aaaform.causeId)
-                    })
-                }
-            })
+                })
+        }
+       
+      
     },
     loadData(e: any) {
+        console.log(e);
         let that = this
-        const { arraySex } = this.data
-        if (e.id) {
+        that.setData({
+            addFig:true
+        })
+        const { arraySex } = that.data
             wx.request({
                 url: submitReport.globalData.url + "/report/rejectReport/" + e.id,
                 method: "GET",
                 header: { 'token': wx.getStorageSync('token') },
                 success: res => {
                     let form = res.data.data
+                    console.log(arraySex,arraySex.findIndex(val=>{return val.sex == form.sex}),form.sex)
+                    
                     this.setData({
+                        remarks:form.remarks,
+                        isInGroup:form.isInGroup,
+                        reportDetail:{
+                            causeId:form.causeId,
+                            id:form.id
+                        },
+                        causeList:[{
+                            id:form.causeId,
+                            name:form.description
+                        }],
+                        causeIndex: 0,
                         aaaform: form,
                         realName: form.realName,
                         phone: form.mobile,
                         userIdCard: form.userIdCard,
                         amountInvolved: form.amountInvolved,
                         sex: form.sex,
-                        sexId: arraySex.filter(i => i.sex == form.sex)[0].code,
+                        sexId: arraySex.findIndex(val=>{return val.sex == form.sex}),
                         Location: form.location,
                         workingLocation: form.workingLocation,
-                        cardIdList: form.idCardMaterials.split(',').map(i => {
+                        cardIdList:form.idCardMaterials? form.idCardMaterials.split(',').map(i => {
                             return {
                                 thumb: that.imgComplete(i),
                                 url: i,
                                 type: "image",
                                 size: 999999
                             }
-                        }),
-                        fileImgList: form.contractMaterials.split(',').map(i => {
+                        }):[],
+                        fileImgList:form.contractMaterials? form.contractMaterials.split(',').map(i => {
                             return {
                                 thumb: that.imgComplete(i),
                                 url: i,
                                 type: "image",
                                 size: 999999
                             }
-                        }),
-                        transactionReceiptList: form.transactionMaterials.split(',').map(i => {
+                        }):[],
+                        transactionReceiptList:form.transactionMaterials? form.transactionMaterials.split(',').map(i => {
                             return {
                                 thumb: that.imgComplete(i),
                                 url: i,
                                 type: "image",
                                 size: 999999
                             }
-                        }),
-                        otherList: form.elseMaterials.split(',').map(i => {
+                        }):[],
+                        otherList:form.elseMaterials? form.elseMaterials.split(',').map(i => {
                             return {
                                 thumb: that.imgComplete(i),
                                 url: i,
                                 type: "image",
                                 size: 999999
                             }
-                        })
+                        }):[]
                     })
+                    console.log(this.data.cardIdList);
+                    
                 }
             })
-        }
+      
+        
     },
     imgComplete(file: String): String {
         return submitReport.globalData.imageUrl + "/img/" + file

--
Gitblit v1.8.0