/*
|
* @Company: hugeInfo
|
* @Author: lwh
|
* @Date: 2025-04-10 10:15:06
|
* @LastEditTime: 2025-05-13 10:42:23
|
* @LastEditors: lwh
|
* @Version: 1.0.0
|
* @Description: 添加办理记录
|
*/
|
import React, { useEffect, useState } from 'react';
|
import { TextareaItem, Button } from 'dingtalk-design-mobile';
|
import { useHistory } from 'react-router-dom';
|
import * as $$ from '../../../utils/utility';
|
import NavBarPage from '../../../components/NavBarPage';
|
import DingUpload from '../../../components/DingUpload';
|
|
import './index.less';
|
|
// 获取id
|
function getNewTimeIdApi(id) {
|
return $$.ax.request({ url: `caseUtils/getNewTimeId`, type: 'get', service: 'utils' });
|
}
|
|
function updateFeedbackApi(data) {
|
return $$.ax.request({ url: `caseFeedback/updateFeedback`, type: 'post', service: 'mediate', data });
|
}
|
|
function saveFeedbackApi(data) {
|
return $$.ax.request({ url: `caseFeedback/saveFeedback`, type: 'post', service: 'mediate', data });
|
}
|
|
const AddRecord = () => {
|
const history = useHistory();
|
const mainId = $$.getQueryString('mainId');
|
const caseId = $$.getQueryString('caseId');
|
const caseTaskId = $$.getQueryString('caseTaskId');
|
const [handleContent, setHandleContent] = useState('');
|
const [fileList, setFileList] = useState([]);
|
const [newId, setNewId] = useState('');
|
|
// 处理提交
|
const handleSubmit = async () => {
|
if (!handleContent) {
|
$$.showToast({ content: '办理意见不能为空' });
|
return;
|
}
|
if (handleContent.length > 500) {
|
$$.showToast({ content: '办理意见不能超过500个字符' });
|
return;
|
}
|
|
// 新增
|
if (!mainId) {
|
global.setSpinning(true);
|
const res = await saveFeedbackApi({
|
handleContent,
|
caseId,
|
caseTaskId,
|
id: newId,
|
});
|
global.setSpinning(false);
|
if (res.type) {
|
$$.showToast({ type: 'success', content: '提交成功' });
|
$$.setLocal('bljl', true);
|
history.goBack();
|
}
|
} else {
|
global.setSpinning(true);
|
const res = await updateFeedbackApi({
|
handleContent,
|
caseId,
|
caseTaskId,
|
id: mainId,
|
});
|
global.setSpinning(false);
|
if (res.type) {
|
$$.showToast({ type: 'success', content: '提交成功' });
|
$$.setLocal('bljl', true);
|
history.goBack();
|
}
|
}
|
};
|
|
// 查看说明材料
|
const handleViewInstructions = () => {
|
console.log('查看说明材料');
|
};
|
|
//获取id
|
const getNewTimeId = async (type) => {
|
const res = await getNewTimeIdApi();
|
if (res.type) {
|
setNewId(res.data);
|
}
|
};
|
|
useEffect(() => {
|
if (!mainId) {
|
getNewTimeId();
|
} else {
|
// 记录在缓存中
|
// sxbl_currentRecord,要做到回显内容
|
const currentRecord = $$.getSessionStorage('sxbl_currentRecord');
|
if (currentRecord) {
|
setHandleContent(currentRecord.handleContent || '');
|
setNewId(mainId);
|
}
|
// 文件列表
|
if (currentRecord.fileInfoList && currentRecord.fileInfoList.length > 0) {
|
setFileList(currentRecord.fileInfoList);
|
}
|
}
|
}, []);
|
|
return (
|
<NavBarPage
|
title="添加办理记录"
|
rightContent={
|
<span className="public-color" onClick={handleViewInstructions}>
|
说明材料
|
</span>
|
}
|
>
|
<div className="add-record">
|
<div className="add-record-content">
|
<div className="add-record-input">
|
<div className="add-record-label">
|
<span className="required-mark">*</span>
|
办理意见
|
</div>
|
<TextareaItem
|
value={handleContent}
|
onChange={(value) => setHandleContent(value)}
|
showCount
|
maxLength={500}
|
placeholder="办理意见应该填写完整,办理意见应具备5要素:调解时间+调解参与部门/人+调解地点+调解过程+调解结果"
|
autoHeight
|
rows={16}
|
/>
|
</div>
|
<div className="add-record-file">
|
<DingUpload
|
title="办理附件"
|
subtitle="可添加办理相关附件"
|
fileList={fileList}
|
mainId={caseId}
|
ownerId={newId}
|
ownerType="22_00018-501"
|
multiple={true}
|
maxCount={9}
|
/>
|
</div>
|
</div>
|
|
<div className="add-record-footer">
|
<Button type="primary" onClick={handleSubmit}>
|
提交
|
</Button>
|
</div>
|
</div>
|
</NavBarPage>
|
);
|
};
|
|
export default AddRecord;
|