Commit e5cd4123 authored by cellee's avatar cellee

Signed-off-by: cellee <893264950@qq.com>

parent 1596dbf3
...@@ -50,17 +50,25 @@ const service = (props: any) => { ...@@ -50,17 +50,25 @@ const service = (props: any) => {
<Space size="middle"> <Space size="middle">
<a <a
onClick={() => { onClick={() => {
emptys(record, `/AccountManagement/service/edit`); edits(record, `/AccountManagement/service/edit`);
}} }}
> >
Edit Add
</a> </a>
<a <a
onClick={() => { onClick={() => {
emptys(record, '/AccountManagement/service/detail'); emptys(record, '/AccountManagement/service/detail');
}} }}
> >
Detail Edit
</a>
<a
onClick={() => {
message.warning('Under development');
}}
>
Download
</a> </a>
</Space> </Space>
), ),
...@@ -86,7 +94,7 @@ const service = (props: any) => { ...@@ -86,7 +94,7 @@ const service = (props: any) => {
} }
}, [location, Init, Data]); }, [location, Init, Data]);
// 清除操作之前的数据 // 清除操作之前的数据 在跳转
const emptys = (data: any, url: any) => { const emptys = (data: any, url: any) => {
// dispatch({ type: module + '/urlRemove' }); // 清掉图片信息 // dispatch({ type: module + '/urlRemove' }); // 清掉图片信息
dispatch({ type: module + '/Result' }); // 清掉之前的删除结果 dispatch({ type: module + '/Result' }); // 清掉之前的删除结果
...@@ -95,6 +103,10 @@ const service = (props: any) => { ...@@ -95,6 +103,10 @@ const service = (props: any) => {
history.push(url + '/' + data.id); history.push(url + '/' + data.id);
}; };
const edits = (data: any, url: any) => {
history.push(url + '/' + data.communityName);
};
// 点击搜索 // 点击搜索
const CallBackTitleSearch = (comment: any) => { const CallBackTitleSearch = (comment: any) => {
......
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-03-02 14:39:40 * @Date: 2021-03-02 14:39:40
* @LastEditTime: 2021-04-22 15:18:59 * @LastEditTime: 2021-05-21 18:01:22
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \tostumi\src\pages\AccountManagement\Service\serviceEdit.tsx * @FilePath: \tostumi\src\pages\AccountManagement\Service\serviceEdit.tsx
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Button, Spin, Form, Input } from 'antd'; import { Button, Spin, Form, Input, message } from 'antd';
import { connect } from 'umi'; import { connect } from 'umi';
import { PlusOutlined } from '@ant-design/icons';
const { TextArea } = Input; const { TextArea } = Input;
import { RA, SA } from '@/utils/method'; import { RA } from '@/utils/method';
const module = 'ServicePro'; const module = 'ServicePro';
import './service.less'; import './service.less';
...@@ -19,100 +20,119 @@ import TitleBack from '@/components/TitleBack/TitleBack'; ...@@ -19,100 +20,119 @@ import TitleBack from '@/components/TitleBack/TitleBack';
import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity'; import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity';
import PictureOptionsRow from '@/components/PictureOptions/PictureOptionsRow'; import PictureOptionsRow from '@/components/PictureOptions/PictureOptionsRow';
import moment from 'moment';
import { getUrlPicName } from '@/utils/string';
const service = (props: any) => { const service = (props: any) => {
const { DataSave, dispatch, loading, match } = props; const { DataSave, dispatch, loading, match, user } = props;
const [term, setTerm] = useState(null as any); // 默认小区 const [term, setTerm] = useState(null as any); // 默认小区
const [ImageSrc, setImageSrc] = useState([] as any); // 图片地址 const [ImageSrc, setImageSrc] = useState([] as any); // 图片地址
const [imgs, setImgs] = useState([] as any); // 回复地址 const [report, setreport] = useState([] as any); // 循环新增的报告
const [form] = Form.useForm(); const [form] = Form.useForm();
// 监听是否有数据 // 监听是否有数据
useEffect(() => { useEffect(() => {
if (match.params.id) { if (match.params.id) {
RA(69, { id: match.params.id }, module, dispatch); console.log(match.params.id);
setTerm(match.params.id);
// RA(69, { id: match.params.id }, module, dispatch);
} }
}, [match]); }, [match]);
useEffect(() => { useEffect(() => {
if (DataSave != null) { if (DataSave != null) {
setTerm({ ...DataSave }); }
}, [DataSave]);
form.setFieldsValue({ //onFinish 提交
communityName: DataSave.communityName, const onFinish = (values: any) => {
reportContent: DataSave.reportContent, // 存储个数
reportImages: DataSave.reportImages ? DataSave.reportImages.split(',') : null, let num = [];
});
if (DataSave.reportPictures.length > 0) { // 先抽取所有的key
// 图片名any let obj = Object.keys(values);
let a = DataSave.reportPictures.map((item: any, i: any) => {
let img = DataSave.reportImages.split(',');
let key = img[i];
return {
uid: i,
name: key,
status: 'done',
url: item,
};
});
// 图片列表
setImageSrc(a);
}
if (DataSave.replyData.length > 0) { // 再看有多少个 值
// 图片名any for (let i in obj) {
let b = [] as any; if (obj[i].indexOf('reportContent') != -1) {
DataSave.replyData[0].replyPictures.map((item: any, i: any) => { num.push(obj[i]);
let obj = {
uid: i,
name: getUrlPicName(item),
status: 'done',
url: item,
};
b.push(obj);
});
// 回复列表
setImgs(b);
form.setFieldsValue({
replyContent: DataSave.replyData[0].replyContent,
});
} }
} }
}, [DataSave]); // 删除第一个
num.splice(num.indexOf('reportContent'), 1);
// 开始拼接
let tosReportRecordModels = [];
// 第一个是都有的
let requte = {
reporterId: user.currentUser.userModel.id,
communityName: values.communityName,
imagesList: values.imagesList,
reportContent: values.reportContent,
};
// 添加进去
tosReportRecordModels.push(requte);
// 如果存在其他的
if (num.length > 0) {
num.forEach((i, idx) => {
let img = 'imagesList' + idx;
let cont = 'reportContent' + idx;
let objs = {
reporterId: user.currentUser.userModel.id,
communityName: values.communityName,
imagesList: values[img],
reportContent: values[cont],
};
tosReportRecordModels.push(objs);
});
}
// 最后结果
let oves = {
tosReportRecordModels,
};
//onFinish 提交 // 再发起请求
const onFinish = (values: any) => { RA(77, oves, module, dispatch);
values.id = match.params.id;
values.reportImages = values.reportImages ? values.reportImages.join(',') : null;
values.replyImages = values.replyImages ? values.replyImages.join(',') : null;
RA(70, values, module, dispatch);
}; };
// 选择小区名字并赋值 // 选择小区名字并赋值
const opname = (value: any) => { const opname = (value: any) => {
// console.log(value); // if (value) {
if (value) { // RA(72, { communityName: value }, module, dispatch);
RA(72, { communityName: value }, module, dispatch); // }
} // setTerm(value);
form.setFieldsValue({ form.setFieldsValue({
communityName: value, communityName: value,
}); });
}; };
// 增加
const addItem = () => {
// 先检查表单内容填完了没
let objs = form.getFieldsValue();
// 存在没填写的就禁止增加
for (let i in objs) {
if (typeof objs[i] === 'undefined') {
message.warning('Please enter all information!');
return false;
}
}
// 再新增
let a = report;
a.push(report.length);
setreport([...a]);
};
return ( return (
<Spin spinning={loading}> <Spin spinning={loading}>
<div className="edit"> <div className="edit">
{/* 标题 */} {/* 标题 */}
<TitleBack title={'Edit report'} /> <TitleBack title={'Add report'} />
{/* 信息 */} {/* 信息 */}
<div className="form_s"> <div className="form_s">
<Form <Form
...@@ -128,31 +148,32 @@ const service = (props: any) => { ...@@ -128,31 +148,32 @@ const service = (props: any) => {
<SearchOptionsCommnity <SearchOptionsCommnity
// ubmit={extendName} // ubmit={extendName}
opname={opname} opname={opname}
defaultName={term ? term.communityName : null} defaultName={term}
// type={1} // 单选还是多选 单选就直接去掉 // type={1} // 单选还是多选 单选就直接去掉
/> />
</Form.Item> </Form.Item>
{/* 小区地址 */}
<Form.Item label="Address">
<span>{term ? `${term.communityAddress} , ${term.postCode}` : null}</span>
</Form.Item>
{/* 报告人 */}
<Form.Item label="Reported By">
<span>{term ? term.reporterName : null}</span>
</Form.Item>
{/* 报告人联系方式 */}
<Form.Item label="Contact Details">
{/* <span style={{ display: 'inline-block', marginRight: 20 }}>
{term ? term.reporterEmail : null}
</span> */}
<span>{term ? term.reporterPhone : null}</span>
</Form.Item>
{/* 报告描述 */} {/* 报告描述 */}
<Form.Item label="Description" name="reportContent" rules={[{ required: true }]}> <Form.Item label="Description" name="reportContent" rules={[{ required: true }]}>
<TextArea rows={4} style={{ maxWidth: 600, width: '100%' }} /> <div className="psoBox flex">
<TextArea rows={4} style={{ maxWidth: 600, width: '100%' }} />
{report.length == 0 ? (
<div className="psoBtn">
<Button
shape="circle"
icon={<PlusOutlined />}
onClick={() => {
addItem();
}}
/>
</div>
) : (
''
)}
</div>
</Form.Item> </Form.Item>
{/* 报告图片 */} {/* 报告图片 */}
<Form.Item label="Picture" name="reportImages" rules={[{ required: true }]}> <Form.Item label="Picture" name="imagesList" rules={[{ required: true }]}>
<PictureOptionsRow <PictureOptionsRow
action="/tos/image/upload" action="/tos/image/upload"
data={{ data={{
...@@ -166,24 +187,51 @@ const service = (props: any) => { ...@@ -166,24 +187,51 @@ const service = (props: any) => {
</Form.Item> </Form.Item>
<hr></hr> <hr></hr>
{/* --------------------------------------------------------------------------------------------- */} {/* --------------------------------------------------------------------------------------------- */}
{/* 回复内容 */}
<Form.Item label="Overview" name="replyContent" rules={[{ required: true }]}> {report.map((i: any, idx: any) => {
<TextArea rows={4} style={{ maxWidth: 600, width: '100%' }} /> return (
</Form.Item> <div key={idx}>
{/* 回复图片 */} <Form.Item
<Form.Item label="Picture" name="replyImages"> label="Description"
<PictureOptionsRow name={'reportContent' + idx}
action="/tos/image/upload" rules={[{ required: true }]}
data={{ >
// imageType: 'tosReportImage', <div className="psoBox flex">
imageType: 'tosReplyImage', <TextArea rows={4} style={{ maxWidth: 600, width: '100%' }} />
identification: '',
}} {idx == report.length - 1 ? (
limitNums={10} <div className="psoBtn">
imgs={imgs} <Button
/> shape="circle"
</Form.Item> icon={<PlusOutlined />}
<hr></hr> onClick={() => {
addItem();
}}
/>
</div>
) : (
''
)}
</div>
</Form.Item>
<Form.Item label="Picture" name={'imagesList' + idx} rules={[{ required: true }]}>
<PictureOptionsRow
action="/tos/image/upload"
data={{
imageType: 'tosReportImage',
identification: '',
}}
limitNums={10}
imgs={ImageSrc}
over={loading}
/>
</Form.Item>
<hr></hr>
</div>
);
})}
{/* --------------------------------------------------------------------------------------------- */} {/* --------------------------------------------------------------------------------------------- */}
{/* 提交 */} {/* 提交 */}
<Form.Item label=" " colon={false}> <Form.Item label=" " colon={false}>
...@@ -199,9 +247,9 @@ const service = (props: any) => { ...@@ -199,9 +247,9 @@ const service = (props: any) => {
}; };
function map(state: any) { function map(state: any) {
const loading = state.loading.models.ServicePro; const loading = state.loading.global;
const Init = state.Init; const { Init, user } = state;
const { DataSave, curString, village } = state[module]; const { DataSave, curString, village } = state[module];
return { DataSave, loading, curString, village, Init }; return { DataSave, loading, curString, village, Init, user };
} }
export default connect(map)(service); export default connect(map)(service);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment