魏熙美 5 年之前
父節點
當前提交
3cec3a304c
共有 1 個文件被更改,包括 15 次插入16 次删除
  1. 15
    16
      src/pages/activity/drainage/Detail.jsx

+ 15
- 16
src/pages/activity/drainage/Detail.jsx 查看文件

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