From 101098593cd1d998979cb8c603276b8f6687942e Mon Sep 17 00:00:00 2001
From: Mr Ke <kelq@hugeinfo.com.cn>
Date: Wed, 08 Apr 2020 14:45:02 +0800
Subject: [PATCH] 修复问卷编辑问题
---
SunshineIns/src/page/CareListEdit.jsx | 93 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 90 insertions(+), 3 deletions(-)
diff --git a/SunshineIns/src/page/CareListEdit.jsx b/SunshineIns/src/page/CareListEdit.jsx
index 26e0f99..5ea8cd8 100644
--- a/SunshineIns/src/page/CareListEdit.jsx
+++ b/SunshineIns/src/page/CareListEdit.jsx
@@ -52,6 +52,7 @@
status: '',
loading: false,
socialTaskObject: '',
+ // rowNum: 4,
editorState: BraftEditor.createEditorState(null),
editorStatetaskProcess: BraftEditor.createEditorState(null),
};
@@ -89,6 +90,7 @@
taskType: res.taskType || 1,
// status: res.activityStatus || '',
socialTaskObject: res.socialTaskObject ? { id: res.socialTaskObject.objectId, objectName: res.socialTaskObject.objectName, taskReport: res.socialTaskObject.taskReport } : {},
+ // rowNum: ReplaceSeperator(res.socialTaskObject.taskReport),
disabled: res.status ? true : false,
fileList: res.attachments || [],
loading: false,
@@ -128,6 +130,16 @@
}
if (!savedate.taskAddress) {
message.warning("任务地点不能为空");
+ return;
+ }
+ if (moment(savedate.startTime) < moment(new Date())) {
+ message.warning("开始时间必须大于当前时间");
+ console.log(moment(savedate.startTime))
+ console.log(moment(new Date()))
+ return;
+ }
+ if (moment(savedate.endTime) < moment(savedate.startTime)) {
+ message.warning("结束时间必须大于开始时间");
return;
}
if (!savedate.taskRequire) {
@@ -294,7 +306,7 @@
submitLContent = () => {
// 在编辑器获得焦点时按下ctrl+s会执行此方法
// 编辑器内容提交到服务端之前,可直接调用editorState.toHTML()来获取HTML格式的内容
- const htmlContent = this.state.editorState.toHTML()
+ const htmlContent = this.state.editorStatetaskProcess.toHTML()
this.setState(({ savedate }) => ({
savedate: {
...savedate,
@@ -303,13 +315,74 @@
}))
}
+ uploadFn = (param) => {
+
+ const serverURL = domain + 'api/v1/attachment/upload'
+ const xhr = new XMLHttpRequest
+ const fd = new FormData()
+ const successFn = (response) => {
+ // 假设服务端直接返回文件上传后的地址
+ // 上传成功后调用param.success并传入上传后的文件地址
+ //Pz
+ const res = JSON.parse(xhr.responseText);
+ param.success({
+ url: domain + 'api/v1/attachment/image/' + res[0].id,
+ meta: {
+ id: res[0].id,
+ title: res[0].name,
+ alt: res[0].name,
+ loop: true, // 指定音视频是否循环播放
+ autoPlay: true, // 指定音视频是否自动播放
+ controls: true, // 指定音视频是否显示控制栏
+ poster: domain + 'api/v1/attachment/image/' + res[0].id, // 指定视频播放器的封面
+ }
+ })
+ }
+
+
+ const progressFn = (event) => {
+ // 上传进度发生变化时调用param.progress
+ param.progress(event.loaded / event.total * 100)
+ }
+
+ const errorFn = (response) => {
+ // 上传发生错误时调用param.error
+ param.error({
+ msg: 'unable to upload.'
+ })
+ }
+ xhr.upload.addEventListener("progress", progressFn, false)
+ xhr.addEventListener("load", successFn, false)
+ xhr.addEventListener("error", errorFn, false)
+ xhr.addEventListener("abort", errorFn, false)
+ fd.append('file', param.file)
+ xhr.open('POST', serverURL, true)
+ xhr.send(fd)
+ }
+
handleEditorChange = (editorState) => {
this.setState({ editorState })
+ const htmlContent = editorState.toHTML()
+ console.log(htmlContent)
+ this.setState(({ savedate }) => ({
+ savedate: {
+ ...savedate,
+ taskRequire: htmlContent
+ }
+ }))
}
handleEditorLChange = (editorStatetaskProcess) => {
this.setState({ editorStatetaskProcess })
+ const htmlContent = editorStatetaskProcess.toHTML()
+ this.setState(({ savedate }) => ({
+ savedate: {
+ ...savedate,
+ taskProcess: htmlContent
+ }
+ }))
}
+
handleCancel = () => this.setState({ previewVisible: false })
render() {
@@ -514,8 +587,8 @@
<div style={divStyle}>
<Row type="flex" align='middle' justify="space-around">
<Col span={6} pull={0} style={{ textAlign: 'center' }}><span>任务汇报</span></Col>
- <Col span={6} push={0} >
- <TextArea disabled={disabled} rows={4} style={{ width: '92%' }} value={socialTaskObject.taskReport || ""} onChange={this.saveInputChange} name='taskReport' />
+ <Col span={18} push={0} >
+ <TextArea disabled={disabled} rows={8} value={socialTaskObject.taskReport || ""} onChange={this.saveInputChange} name='taskReport' />
</Col>
<Col span={12} pull={0}></Col>
</Row>
@@ -573,3 +646,17 @@
}
}
+
+function ReplaceSeperator(mobiles) {
+ var i;
+ var result = "";
+ var c;
+ for (i = 0; i < mobiles.length; i++) {
+ c = mobiles.substr(i, 1);
+ if (c == "\n")
+ result = result + "<br/>";
+ // else if (c != "\r")
+ // result = result + c;
+ }
+ return result;
+}
\ No newline at end of file
--
Gitblit v1.8.0