dingxin 5 years ago
parent
commit
58bdf39339
1 changed files with 14 additions and 7 deletions
  1. 14
    7
      src/pages/activity/drainage/Detail.jsx

+ 14
- 7
src/pages/activity/drainage/Detail.jsx View File

36
       console.log(data, '3333333333333')
36
       console.log(data, '3333333333333')
37
       if (data.total != 0) {
37
       if (data.total != 0) {
38
         setTotal(data)
38
         setTotal(data)
39
-        // console.log(data.total, '3333333333333')
40
-
41
         setDatas(tableData(data.records))
39
         setDatas(tableData(data.records))
42
         // content = data.records[0]
40
         // content = data.records[0]
43
         console.log('json: ', eval('(' + data.records[0].content + ')'))
41
         console.log('json: ', eval('(' + data.records[0].content + ')'))
44
         setContent(eval('(' + data.records[0].content + ')'))
42
         setContent(eval('(' + data.records[0].content + ')'))
45
-        setColumns(tableTitle(eval('(' + data.records[0].content + ')')))
43
+        setColumns(tableTitle(data.records))
46
       }
44
       }
47
       else {
45
       else {
48
         setDatas([])
46
         setDatas([])
57
     })
55
     })
58
   }
56
   }
59
   function tableData (data) {
57
   function tableData (data) {
60
-    console.log('data', data)
58
+    console.log('tabledata', data)
61
     return data.map((row, inx) => {
59
     return data.map((row, inx) => {
62
       return eval('(' + row.content + ')').reduce((acc, col) => {
60
       return eval('(' + row.content + ')').reduce((acc, col) => {
63
         const r = {
61
         const r = {
62
+
64
           key: inx + 1,
63
           key: inx + 1,
64
+          createDate:row.createDate,
65
           [`${col.key}`]: col.value,
65
           [`${col.key}`]: col.value,
66
           ...acc,
66
           ...acc,
67
         }
67
         }
72
   }
72
   }
73
 
73
 
74
   function tableTitle (data) {
74
   function tableTitle (data) {
75
-    return data.map((item) => {
75
+   tableTitle = eval('(' + data[0].content + ')')
76
+    const cols = [{
77
+      title: "提交时间",
78
+      dataIndex: "createDate",
79
+      key: "createDate",
80
+      render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
81
+    }]
82
+    return cols.concat( tableTitle.map((item) => {
76
       const col = {
83
       const col = {
77
         title: item.label,
84
         title: item.label,
78
         dataIndex: item.key,
85
         dataIndex: item.key,
79
         key: item.key
86
         key: item.key
80
       }
87
       }
81
       return col
88
       return col
82
-    })
89
+    }))
83
   }
90
   }
84
 
91
 
85
 
92
 
106
 
113
 
107
   function excelPort () {
114
   function excelPort () {
108
     // const fieldsValue = getFieldsValue()
115
     // const fieldsValue = getFieldsValue()
109
-    console.log("111111")
116
+  
110
     request({ ...apis.activity.exporttaDrainageRecord, params: { drainageId: drainageId, startTime: fromTime(startDate), endTime: fromTime(endDate) } })
117
     request({ ...apis.activity.exporttaDrainageRecord, params: { drainageId: drainageId, startTime: fromTime(startDate), endTime: fromTime(endDate) } })
111
       .then(response => {
118
       .then(response => {
112
         download(response)
119
         download(response)