广州市综治平台前端
liuwh
6 days ago be89af3bf4d7e591ef085f55f1de7c28fcf5f6a8
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
import React, { useEffect, useState } from 'react';
import { Modal, Tag, Space } from 'antd';
import TableView from '@/components/TableView';
import PreviewImage from '@/components/PreviewImage';
import * as $$ from '@/utils/utility';
import './index.less';
import { ledger_2,Frame_2 } from '../../assets/images';
// 获取修改记录列表
function getModifyRecordApi(caseId) {
  return $$.ax.request({ 
    url: 'cases/modify-record/group-by-time-user', 
    type: 'get',
    data: { caseId },
    service: 'mediate' 
  });
}
 
// 获取修改记录详情
function getModifyDetailApi(params) {
  return $$.ax.request({ 
    url: 'cases/modify-record/detail', 
    type: 'get',
    data: params,
    service: 'mediate' 
  });
}
 
const CaseUpdateInfo = ({ 
  visible = false, 
  onCancel,
  caseId
}) => {
  const [recordList, setRecordList] = useState([]);
  const [loading, setLoading] = useState(false);
  const [detailVisible, setDetailVisible] = useState(false);
  const [detailLoading, setDetailLoading] = useState(false);
  const [detailData, setDetailData] = useState([]);
  const [currentRecord, setCurrentRecord] = useState(null);
 
  // 获取修改记录列表
  const getModifyRecord = async () => {
    if (!caseId) return;
    
    setLoading(true);
    try {
      const res = await getModifyRecordApi(caseId);
      if (res.type) {
        setRecordList(res.data || []);
      }
    } catch (error) {
      console.error('获取修改记录失败', error);
    } finally {
      setLoading(false);
    }
  };
 
  // 获取修改记录详情
  const getModifyDetail = async (record) => {
    setDetailLoading(true);
    try {
      const res = await getModifyDetailApi({
        caseId,
        modifyTime: record.modifyTime,
        modifyUser: record.modifyUser
      });
      if (res.type) {
        setDetailData(res.data || []);
      }
    } catch (error) {
      console.error('获取修改详情失败', error);
    } finally {
      setDetailLoading(false);
    }
  };
 
  // 处理查看详情
  const handleViewDetail = (record) => {
    setCurrentRecord(record);
    setDetailVisible(true);
    getModifyDetail(record);
  };
 
  useEffect(() => {
    if (visible && caseId) {
      getModifyRecord();
    }
  }, [visible, caseId]);
 
  // 详情表格列定义
  const detailColumns = [
    {
      title: '类型',
      dataIndex: 'modifyType',
      key: 'modifyType',
      width: 80,
      render: (text) => {
        const typeMap = {
          '修改': <span className="modify-type-tag modify-type-edit">修改</span>,
          '添加': <span className="modify-type-tag modify-type-add">添加</span>,
          '删除': <span className="modify-type-tag modify-type-delete">删除</span>
        };
        return typeMap[text] || text;
      }
    },
    {
      title: '修改内容',
      dataIndex: 'modifyAttribute',
      key: 'modifyAttribute',
      width: '10%'
    },
    {
      title: '修改项',
      dataIndex: 'modifyItem',
      key: 'modifyItem',
      width: '10%'
    },
 
    {
      title: '修改前',
      dataIndex: 'beforeContent',
      key: 'beforeContent',
      width: '40%',
      render: (text, record) => {
        if (record.fileUrl && record.modifyType === '删除') {
          return <div style={{ display: 'inline-block' }}>
          <PreviewImage name={record.beforeContent} src={record.fileUrl} />
          {/* {index !== props.transactResult?.fileInfoBaseDTOList.length - 1 && <>,</>} */}
        </div>
        }
        return text || '-';
      }
    },
    {
      title: '修改后',
      dataIndex: 'afterContent',
      key: 'afterContent',
      width: '40%',
      render: (text, record) => {
        if (record.fileUrl && record.modifyType !== '删除') {
          return <div style={{ display: 'inline-block' }}>
          <PreviewImage name={record.afterContent} src={record.fileUrl} />
          {/* {index !== props.transactResult?.fileInfoBaseDTOList.length - 1 && <>,</>} */}
        </div>
        }
        return text || '-';
      }
    }
  ];
 
  return (
    <>
      <Modal
        title="查看修改日志"
        open={visible}
        onCancel={onCancel}
        width={1200}
        style={{
          top: 100,
          maxWidth: 1600
        }}
        bodyStyle={{
          height: 552
        }}
        footer={null}
        destroyOnClose
        className="case-repeat-info-modal"
        maskClosable={false}
        zIndex={100}
      >
        <div className="case-repeat-info">
          {loading ? (
            <div className="loading-tip">
              <div className="loading-content">加载中...</div>
            </div>
          ) : (
            <>
              {recordList.length > 0 ? (
                <>
                  <div className="info-tip">
                    <i className="info-icon"></i>
                    <span>事项在办结后共计修改<span style={{ color: '#1A6FB8' }}>{recordList.length}</span>次,详情如下</span>
                  </div>
                  <div className="record-list">
                    {recordList.map((record, index) => (
                      <div className="record-item" key={index}>
                        <div className="record-icon">
                          <img src={Frame_2} className="time-icon" />
                        </div>
                        <div className="record-content">
                          <div className="record-time">{record.modifyTime}</div>
                          <div className="record-info-row">
                            <div className="record-info">
                              <span className="label">修改人:</span>
                              <span className="value">{record.modifyUser}</span>
                              <span className="user-dept">{record.userDept}</span>
                            </div>
                            <div className="record-info">
                              <span className="label">修改内容:</span>
                              <span className="value">{record.modifyCount}项</span>
                            </div>
                          </div>
                        </div>
                        <div className="record-action">
                          <span className="view-btn" onClick={() => handleViewDetail(record)}>查看</span>
                        </div>
                      </div>
                    ))}
                  </div>
                </>
              ) : (
                <div className="empty-tip">
                  <div className="empty-content">暂无修改记录</div>
                </div>
              )}
            </>
          )}
        </div>
      </Modal>
 
      {/* 修改详情弹窗 */}
      <Modal
        title="修改日志详情"
        open={detailVisible}
        onCancel={() => setDetailVisible(false)}
        width="calc(100% - 32px)"
        style={{
          top: 20,
          maxWidth: 1600,
          overflow: 'auto'
        }}
        footer={null}
        destroyOnClose
        className="case-repeat-detail-modal"
        maskClosable={false}
        zIndex={101}
      >
        <div className="case-repeat-detail">
          <div className="detail-header">
            <div className="info-tip">
              <i className="info-icon"></i>
              <span>事项办结后修改详情如下</span>
            </div>
            
            {currentRecord && (
              <div className="detail-info-row">
                <div className="info-item">
                  <span className="label">修改时间:</span>
                  <span className="value">{currentRecord.modifyTime}</span>
                </div>
                <div className="info-item">
                  <span className="label">修改人:</span>
                  <span className="value">{currentRecord.modifyUser}</span>
                  <span className="user-dept">{currentRecord.userDept}</span>
                </div>
              </div>
            )}
          </div>
          
          <TableView
            columns={detailColumns}
            dataSource={detailData}
            rowKey="id"
            loading={detailLoading}
            pagination={false}
            bordered={true}
            className="detail-table"
            locale={{
              emptyText: <div className="empty-content">暂无修改详情</div>
            }}
          />
        </div>
      </Modal>
    </>
  );
};
 
export default CaseUpdateInfo;