tony.cheng
2026-01-27 6a77991808ba41650e646afd247b17fa3903c6e4
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
import React, { useState } from 'react';
import { Input, DatePicker, Button, Pagination, Spin, Modal } from 'antd';
import { SearchOutlined, RedoOutlined } from '@ant-design/icons';
import LawDetailContent from './LawDetailContent';
import './LawSearchContent.css';
 
// Mock数据 - 按原型格式
const mockLawList = [
  {
    id: 'law-001',
    lawName: '中华人民共和国民法典',
    effectLevel: '法律',
    status: '有效',
    org: '全国人民代表大会',
    publishDate: '2020-05-28',
    effectiveDate: '2021-01-01',
    articles: [
      { number: '第五条', content: '民事主体从事民事活动,应当遵循自愿原则,按照自己的意思设立、变更、终止民事法律关系。' },
      { number: '第六条', content: '民事主体从事民事活动,应当遵循公平原则,合理确定各方的权利和义务。' },
    ],
  },
  {
    id: 'law-002',
    lawName: '中华人民共和国劳动法',
    effectLevel: '法律',
    status: '有效',
    org: '全国人民代表大会',
    publishDate: '2018-12-29',
    effectiveDate: '2019-01-01',
    articles: [
      { number: '第五十条', content: '工资应当以货币形式按月支付给劳动者本人。不得克扣或者无故拖欠劳动者的工资。' },
      { number: '第九十一条', content: '用人单位有下列侵害劳动者合法权益情形之一的,由劳动行政部门责令支付劳动者的工资报酬、经济补偿,并可以责令支付赔偿金。' },
    ],
  },
  {
    id: 'law-003',
    lawName: '中华人民共和国劳动合同法',
    effectLevel: '法律',
    status: '有效',
    org: '全国人民代表大会常务委员会',
    publishDate: '2012-12-28',
    effectiveDate: '2013-07-01',
    articles: [
      { number: '第三十条', content: '用人单位应当按照劳动合同约定和国家规定,向劳动者及时足额支付劳动报酬。' },
    ],
  },
  {
    id: 'law-004',
    lawName: '中华人民共和国社会保险法',
    effectLevel: '法律',
    status: '有效',
    org: '全国人民代表大会常务委员会',
    publishDate: '2018-12-29',
    effectiveDate: '2019-01-01',
    articles: [],
  },
  {
    id: 'law-005',
    lawName: '最高人民法院关于审理劳动争议案件适用法律问题的解释(一)',
    effectLevel: '司法解释',
    status: '有效',
    org: '最高人民法院',
    publishDate: '2020-12-29',
    effectiveDate: '2021-01-01',
    articles: [],
  },
];
 
// 筛选器配置
const filterConfig = {
  lawNature: [
    { label: '法律', count: 256, checked: true },
    { label: '法律解释', count: 33, checked: false },
    { label: '有关法律问题和重大问题的决定', count: 12, checked: false },
    { label: '修改、废止的决定', count: 8, checked: false },
  ],
  org: [
    { label: '全国人民代表大会', count: 256, checked: true },
    { label: '全国人民代表大会常务委员会', count: 256, checked: false },
    { label: '国务院', count: 21, checked: false },
    { label: '地方各级人民代表大会', count: 8, checked: false },
    { label: '人民法院', count: 21, checked: false },
    { label: '人民检察院', count: 8, checked: false },
  ],
  validity: [
    { label: '有效', count: 33, checked: true },
    { label: '尚未生效', count: 33, checked: false },
    { label: '已废止', count: 12, checked: false },
    { label: '已修改', count: 21, checked: false },
    { label: '其他', count: 8, checked: false },
  ],
};
 
/**
 * 法条搜索内容组件(用于弹窗内显示)- 与原型 law_search.html 保持一致
 */
const LawSearchContent = () => {
  const [loading, setLoading] = useState(false);
  const [keyword, setKeyword] = useState('民事主体从事民事活动');
  const [list, setList] = useState(mockLawList);
  const [activeId, setActiveId] = useState('law-001');
  const [filters, setFilters] = useState(filterConfig);
  const [currentPage, setCurrentPage] = useState(1);
  const [detailVisible, setDetailVisible] = useState(false);
  const [selectedLawId, setSelectedLawId] = useState(null);
  const pageSize = 10;
  const total = 256;
 
  const handleSearch = () => {
    setLoading(true);
    setTimeout(() => {
      setList(mockLawList);
      setLoading(false);
    }, 300);
  };
 
  const handleReset = () => {
    setKeyword('');
    setFilters(filterConfig);
  };
 
  const toggleFilter = (category, index) => {
    setFilters((prev) => {
      const newFilters = { ...prev };
      newFilters[category] = [...prev[category]];
      newFilters[category][index] = {
        ...newFilters[category][index],
        checked: !newFilters[category][index].checked,
      };
      return newFilters;
    });
  };
 
  const handleLawItemClick = (lawId) => {
    if (activeId === lawId) {
      // 如果已经是激活状态,再次点击弹出详情
      setSelectedLawId(lawId);
      setDetailVisible(true);
    } else {
      setActiveId(lawId);
    }
  };
 
  return (
    <div className="law-search-container">
      {/* 查询条件区域 */}
      <div className="law-search-query-conditions">
        <h2 className="law-search-query-title">
          <i className="fas fa-search"></i>
          查询条件
        </h2>
        <div className="law-search-query-form">
          <div className="law-search-form-group">
            <label className="law-search-form-label">关键词</label>
            <Input
              value={keyword}
              onChange={(e) => setKeyword(e.target.value)}
              placeholder="请输入关键词"
            />
          </div>
          <div className="law-search-form-group">
            <label className="law-search-form-label">公布日期</label>
            <div className="law-search-date-input-group">
              <DatePicker placeholder="开始日期" style={{ flex: 1 }} />
              <span className="law-search-date-separator">至</span>
              <DatePicker placeholder="结束日期" style={{ flex: 1 }} />
            </div>
          </div>
          <div className="law-search-form-group full-width">
            <div className="law-search-button-group">
              <Button type="primary" icon={<SearchOutlined />} onClick={handleSearch} loading={loading}>
                查询
              </Button>
              <Button icon={<RedoOutlined />} onClick={handleReset}>
                重置条件
              </Button>
            </div>
          </div>
        </div>
      </div>
 
      {/* 筛选器区域 */}
      <div className="law-search-filters-section">
        <div className="law-search-filters-grid">
          {/* 法律性质 */}
          <div className="law-search-filter-category">
            <h3 className="law-search-filter-title">法律性质</h3>
            <div className="law-search-filter-list">
              {filters.lawNature.map((item, index) => (
                <div
                  key={index}
                  className="law-search-filter-item"
                  onClick={() => toggleFilter('lawNature', index)}
                >
                  <div className={`law-search-filter-checkbox ${item.checked ? 'checked' : ''}`}>
                    {item.checked && <i className="fas fa-check"></i>}
                  </div>
                  <span>
                    {item.label} ({item.count})
                  </span>
                </div>
              ))}
            </div>
          </div>
 
          {/* 制定机关 */}
          <div className="law-search-filter-category">
            <h3 className="law-search-filter-title">制定机关</h3>
            <div className="law-search-filter-list">
              {filters.org.map((item, index) => (
                <div key={index} className="law-search-filter-item" onClick={() => toggleFilter('org', index)}>
                  <div className={`law-search-filter-checkbox ${item.checked ? 'checked' : ''}`}>
                    {item.checked && <i className="fas fa-check"></i>}
                  </div>
                  <span>
                    {item.label} ({item.count})
                  </span>
                </div>
              ))}
            </div>
          </div>
 
          {/* 时效性 */}
          <div className="law-search-filter-category">
            <h3 className="law-search-filter-title">时效性</h3>
            <div className="law-search-filter-list">
              {filters.validity.map((item, index) => (
                <div
                  key={index}
                  className="law-search-filter-item"
                  onClick={() => toggleFilter('validity', index)}
                >
                  <div className={`law-search-filter-checkbox ${item.checked ? 'checked' : ''}`}>
                    {item.checked && <i className="fas fa-check"></i>}
                  </div>
                  <span>
                    {item.label} ({item.count})
                  </span>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
 
      {/* 查询结果区域 */}
      <div className="law-search-results-section">
        <div className="law-search-results-header">
          <h2 className="law-search-results-title">查询结果</h2>
          <div className="law-search-page-info">记录总数:{total}条</div>
        </div>
 
        <Spin spinning={loading}>
          <div className="law-search-laws-list">
            {list.map((law) => (
              <div
                key={law.id}
                className={`law-search-law-item ${activeId === law.id ? 'active' : ''}`}
                onClick={() => handleLawItemClick(law.id)}
              >
                <h3 className="law-search-law-title">{law.lawName}</h3>
                <div className="law-search-law-meta">
                  <div className="law-search-law-meta-item">
                    <i className="fas fa-check-circle status-valid"></i>
                    <span>时效性:{law.status}</span>
                  </div>
                  <div className="law-search-law-meta-item">
                    <i className="fas fa-layer-group"></i>
                    <span>法律效力位阶:{law.effectLevel}</span>
                  </div>
                  <div className="law-search-law-meta-item">
                    <i className="fas fa-landmark"></i>
                    <span>制定机关:{law.org}</span>
                  </div>
                  <div className="law-search-law-meta-item">
                    <i className="far fa-calendar-alt"></i>
                    <span>公布日期:{law.publishDate}</span>
                  </div>
                  <div className="law-search-law-meta-item">
                    <i className="far fa-calendar-check"></i>
                    <span>实施日期:{law.effectiveDate}</span>
                  </div>
                </div>
                {/* 条文内容 - 仅在选中状态显示 */}
                {activeId === law.id && law.articles && law.articles.length > 0 && (
                  <div className="law-search-law-content">
                    {law.articles.map((article, index) => (
                      <div className="law-search-law-article" key={index}>
                        <span className="law-search-article-number">{article.number}</span>
                        <span>{article.content}</span>
                      </div>
                    ))}
                  </div>
                )}
              </div>
            ))}
          </div>
        </Spin>
 
        {/* 分页 */}
        <div className="law-search-pagination">
          <Pagination
            current={currentPage}
            pageSize={pageSize}
            total={total}
            onChange={(page) => setCurrentPage(page)}
            showSizeChanger={false}
            showQuickJumper
            showTotal={(total, range) => `第 ${range[0]}-${range[1]} 条 / 共 ${total} 条`}
          />
        </div>
      </div>
 
      {/* 详情弹窗 */}
      <Modal
        title={
          <div style={{ fontSize: '1.2rem', fontWeight: 600 }}>
            <i className="fas fa-book" style={{ marginRight: 10, color: '#1a6fb8' }}></i>
            法律条文详情
          </div>
        }
        visible={detailVisible}
        onCancel={() => setDetailVisible(false)}
        footer={null}
        width={1000}
        bodyStyle={{ padding: 0, height: '80vh', overflow: 'hidden' }}
        centered
        destroyOnClose
      >
        <LawDetailContent lawId={selectedLawId} />
      </Modal>
    </div>
  );
};
 
export default LawSearchContent;