forked from gzzfw/frontEnd/gzDyh

dminyi
2024-08-09 a2a5220469a3e1f8bc216f47c887ca4c941920b0
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
/*
 * @Company: hugeInfo
 * @Author: xzx
 * @Date: 2022-04-19 11:27:07
 * @LastEditors: lwh
 * @LastEditTime: 2023-07-13 14:32:50
 * @Version: 1.0.0
 * @Description:  我的司法确认
 */
import React, { useEffect, useState } from 'react';
import Page from '../../../components/Page/index';
import { Form, Typography } from 'antd';
import * as $$ from '../../../utils/utility';
import { useLocation, useNavigate } from 'react-router-dom';
import TableView from '../../../components/TableView';
import TableSearch from '../../../components/TableSearch';
import MyTabs from '../../../components/MyTabs';
import publicDataStatus from '../../../status/publicData';
 
const { Link } = Typography;
 
// 司法确认列表接口api
function getMyConfirmationDataApi(submitData) {
  return $$.ax.request({ url: 'judicTask/pageMyTask', type: 'get', data: submitData, service: 'mediate' });
}
 
const MyConfirmation = () => {
  const [form] = Form.useForm();
 
  let location = useLocation();
 
  let navigate = useNavigate();
 
  // 搜索
  const [search, setSearch] = useState({ page: 1, size: 10, pageType: '0', joinRole: '1' });
 
  // 数据
  const [data, setData] = useState({ tableData: [] });
 
  // 调解组织select框数据
  const [adjustOrgData, setAdjustOrgData] = useState([]);
 
  // 表头
  const columns = () => {
    return [
      { title: '司法确认案号', dataIndex: 'judicNo' },
      { title: '司法确认进度', dataIndex: 'processName' },
      ...(search.pageType === '2'
        ? [
          {
            title: '司法确认结果',
            dataIndex: 'judicResult',
            render: (text, record) => (
              <span className={`public-tag public-tag-${text === '22_00028-1' ? 'tagGreen' : 'tagRed'}`}>{record.judicResultName}</span>
            ),
          },
        ]
        : []),
      { title: '申请人', dataIndex: 'plaintiffs' },
      { title: '被申请人', dataIndex: 'defendants' },
      { title: '纠纷发生地', dataIndex: 'addr' },
      { title: '纠纷类型', dataIndex: 'caseTypeName' },
      { title: '申请时间', dataIndex: 'applyTime' },
      { title: '调解成功时间', dataIndex: 'mediEndTime' },
      { title: '调解组织', dataIndex: 'mediateUnitName' },
      ...(search.joinRole === '2' ? [{ title: '承办法官', dataIndex: 'judgeName' }] : []),
      { title: '助理/书记员', dataIndex: 'assistName' },
      {
        title: '操作',
        dataIndex: 'action',
        width: 50,
        render: (_, record) => {
          let type = 'check';
          if (search.joinRole === '1' && (search.pageType === '0' || search.pageType === '1')) {
            type = 'handle';
          }
          if (search.joinRole === '2' && (search.pageType === '0' || search.pageType === '1')) {
            type = 'feedback';
          }
          if (search.joinRole === '2' && search.pageType === '2' && record.feedbackStatus === '1') {
            type = 'feedback';
          }
          return <Link onClick={() => handleJump(type, record)}>{type === 'check' ? '查看' : '处理'}</Link>;
        },
      },
    ];
  };
 
  // 跳转页面
  function handleJump(type, info) {
    if (type === 'feedback') {
      // 协助反馈
      $$.setSessionStorage(location.pathname, {
        search,
        breadcrumbData: [{ title: '我的司法确认', url: '/mediate/myConfirmation' }, { title: '我协助的' }],
        title: info.judicNo,
        tableActive: info.id,
        tabs: [{ label: '司法确认', key: 'feedBack' }],
        pageFrom: 'myConfirmationFeedBack',
      });
      navigate(`/mediate/caseDetail?caseId=${info.caseId}&judicialId=${info.judicId}&back=${location.pathname}`);
    }
    if (type === 'check') {
      // 查看
      $$.setSessionStorage(location.pathname, {
        search,
        breadcrumbData: [{ title: '我的司法确认', url: '/mediate/myConfirmation' }, { title: '详情' }],
        title: info.judicNo,
        pageFrom: 'myConfirmation',
        tableActive: info.id,
      });
      navigate(`/mediate/caseDetail?caseId=${info.caseId}&judicialId=${info.judicId}&back=${location.pathname}`);
    }
    if (type === 'handle') {
      // 司法确认
      if (info.serieStatus === '2') {
        // 系列案
        $$.setSessionStorage(location.pathname, {
          search,
          breadcrumbData: [{ title: '我的司法确认', url: '/mediate/myConfirmation' }, { title: '我负责的' }],
          title: info.judicNo,
          tableActive: info.id,
          tabs: [{ label: '司法确认', key: 'caseFolderFeedBack' }],
          pageFrom: 'myConfirmationCaseFolderFeedBack',
        });
        navigate(`/mediate/caseDetail?caseId=${info.caseId}&judicialId=${info.judicId}&taskId=${info.id}&back=${location.pathname}`);
      } else {
        // 非系列案
        $$.setSessionStorage(location.pathname, {
          search,
          tableActive: info.id,
        });
        navigate(
          `/mediate/myConfirmation/judicialWindow?caseId=${info.caseId}&judicialId=${info.judicId}&taskId=${info.id}&back=${location.pathname}`
        );
      }
    }
  }
 
  // 页码修改
  function handleChangePage(page, pageSize) {
    getMyConfirmationData({ ...search, page, size: pageSize });
  }
 
  // 搜索 or 重置
  function handleSearch(type, session) {
    let paramsObj = {};
    if (type === 'search') {
      paramsObj = { ...search, ...form.getFieldsValue(), page: 1 };
      $$.changeTimeFormat(paramsObj, 'applyTime', 'applyStart', 'applyEnd');
      $$.changeTimeFormat(paramsObj, 'mediEndTime', 'mediEndTimeStart', 'mediEndTimeEnd');
      if (paramsObj.judicResult) {
        paramsObj.pageType = '2';
      }
    }
    if (type === 'reset') {
      paramsObj = { page: 1, size: 10, pageType: '0', joinRole: '1' };
      form.resetFields();
      form.setFieldsValue({ joinRole: '1' });
    }
    if (type === 'recurrent') {
      paramsObj = { ...search, ...session.search };
      let copyObj = { ...paramsObj };
      if (copyObj.applyStart) {
        copyObj.applyTime = [$$.myMoment(copyObj.applyStart), $$.myMoment(copyObj.applyEnd)];
      }
      if (copyObj.mediEndTimeStart) {
        copyObj.mediEndTime = [$$.myMoment(copyObj.mediEndTimeStart), $$.myMoment(copyObj.mediEndTimeEnd)];
      }
      form.setFieldsValue(copyObj);
    }
    getMyConfirmationData(paramsObj, session?.tableActive);
  }
 
  // 获取数据
  async function getMyConfirmationData(submitData, tableActive) {
    global.setSpinning(true);
    const res = await getMyConfirmationDataApi(submitData);
    global.setSpinning(false);
    if (res.type) {
      setSearch(submitData);
      setData({
        total: res.data?.dtoPage?.totalElements,
        tableData: res.data?.dtoPage?.content || [],
        tableActive,
        countDks: res.data.countDks,
        countJxz: res.data.countJxz,
        countYjs: res.data.countYjs,
      });
    }
  }
 
  // 初始化
  useEffect(() => {
    publicDataStatus.getUnitData((data) => setAdjustOrgData(data));
    let values = $$.getSessionStorage(location.pathname);
    if ($$.getQueryString('isBack') && !!values) {
      handleSearch('recurrent', values);
    } else {
      handleSearch('reset');
    }
    if (!!values) {
      $$.clearSessionStorage(location.pathname);
    }
  }, []);
 
  const dks = (search.pageType === '0' ? data.total : data.countDks) || 0;
 
  const jxz = (search.pageType === '1' ? data.total : data.countJxz) || 0;
 
  const yjs = (search.pageType === '2' ? data.total : data.countYjs) || 0;
 
  return (
    <Page pageHead={{ title: '我的司法确认', subtitle: '个人名下司法确认案件列表' }}>
      <div className="myConfirmation">
        <div className="pageSearch">
          <TableSearch
            labelLength={6}
            form={form}
            itemData={[
              { type: 'Input', name: 'plaintiffs', label: '申请人' },
              { type: 'Input', name: 'defendants', label: '被申请人' },
              { type: 'RangePicker', name: 'applyTime', label: '申请时间' },
              { type: 'Input', name: 'judicNo', label: '司法确认案号' },
              { type: 'Input', name: 'addr', label: '纠纷发生地' },
              {
                type: 'Select',
                name: 'joinRole',
                allowClear: false,
                label: '参与角色',
                selectdata: [
                  { label: '我负责的', value: '1' },
                  { label: '我协助的', value: '2' },
                ],
              },
              { type: 'RangePicker', name: 'mediEndTime', label: '调解成功时间' },
              { type: 'Select', name: 'judicResult', label: '司法确认结果', selectdata: $$.options.judicResult },
              { type: 'TreeSelect', name: 'applyUnitId', label: '调解组织', treedata: adjustOrgData },
            ]}
            handleReset={() => handleSearch('reset')}
            handleSearch={() => handleSearch('search')}
          />
        </div>
        <div className="pageTabs">
          <MyTabs
            tabs={[
              { key: '0', label: `待开始(${$$.showMoreNum(dks)})` },
              { key: '1', label: `进行中(${$$.showMoreNum(jxz)})` },
              { key: '2', label: `已结束(${$$.showMoreNum(yjs)})` },
            ]}
            activeKey={search.pageType}
            onChange={(activeKey) => getMyConfirmationData({ ...search, page: 1, size: 10, pageType: activeKey })}
          />
        </div>
        <div className="pageTable">
          <TableView
            showHeader
            title="查询结果"
            columns={columns()}
            dataSource={data.tableData}
            pagination={{
              current: search.page,
              pageSize: search.size,
              total: data.total,
              onChange: (page, pageSize) => handleChangePage(page, pageSize),
            }}
            rowClassName={(record) => (record.id === data.tableActive ? 'tableRowActive' : '')}
          />
        </div>
      </div>
    </Page>
  );
};
 
export default MyConfirmation;