From 63182747f71b49799c4e1e4f8df8d988a194b146 Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Fri, 13 Mar 2020 17:26:21 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E8=AF=84=E8=AE=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/forge/Order/Detail.js | 18 ++++++++++++++++--
public/react/src/forge/Order/New.js | 16 ++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/public/react/src/forge/Order/Detail.js b/public/react/src/forge/Order/Detail.js
index 5d13b9e62..023644a69 100644
--- a/public/react/src/forge/Order/Detail.js
+++ b/public/react/src/forge/Order/Detail.js
@@ -7,7 +7,8 @@ import UploadComponent from '../Upload/Index';
import { getImageUrl } from 'educoder';
import {Modal, Col, Form, Input, Tooltip, Popconfirm, Pagination , Spin} from 'antd'
import NoneData from '../../modules/courses/coursesPublic/NoneData';
-import Attachments from '../Upload/attachment'
+import Attachments from '../Upload/attachment';
+import QuillForEditor from '../quillForEditor';
const TextArea = Input.TextArea;
@@ -441,7 +442,20 @@ class Detail extends Component{
required: true, message: '请输入内容'
}],
})(
-
+
)}
diff --git a/public/react/src/forge/Order/New.js b/public/react/src/forge/Order/New.js
index 63c8e8f01..64c1f48c5 100644
--- a/public/react/src/forge/Order/New.js
+++ b/public/react/src/forge/Order/New.js
@@ -12,6 +12,22 @@ import axios from 'axios';
const Option = Select.Option;
const TextArea = Input.TextArea;
+{/* */}
class New extends Component{
constructor(props){
super(props);
From c7dbe2466d7abb6a033fdb31c090f23858647318 Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Mon, 16 Mar 2020 17:26:24 +0800
Subject: [PATCH 2/2] quill
---
public/react/src/Loading.js | 11 +--
public/react/src/forge/Order/Detail.js | 89 +++++++++++++------
public/react/src/forge/Order/New.js | 18 +---
public/react/src/forge/Order/order.css | 17 +++-
.../react/src/forge/quillForEditor/index.js | 2 +-
.../react/src/forge/quillForEditor/index.scss | 3 +
6 files changed, 85 insertions(+), 55 deletions(-)
diff --git a/public/react/src/Loading.js b/public/react/src/Loading.js
index e05a36a54..f341959c2 100644
--- a/public/react/src/Loading.js
+++ b/public/react/src/Loading.js
@@ -1,15 +1,12 @@
import React, { Component } from 'react';
-
-import { BrowserRouter as Router, Route, Link } from "react-router-dom";
-
import { Spin } from 'antd';
class Loading extends Component {
componentDidUpdate(prevProps, prevState) {
- if (!prevProps.error && this.props.error) {
- console.log(this.props.error)
- window.location.reload()
- }
+ if (!prevProps.error && this.props.error) {
+ console.log(this.props.error)
+ window.location.reload()
+ }
}
render() {
diff --git a/public/react/src/forge/Order/Detail.js b/public/react/src/forge/Order/Detail.js
index 023644a69..cdc7293bb 100644
--- a/public/react/src/forge/Order/Detail.js
+++ b/public/react/src/forge/Order/Detail.js
@@ -9,10 +9,17 @@ import {Modal, Col, Form, Input, Tooltip, Popconfirm, Pagination , Spin} from '
import NoneData from '../../modules/courses/coursesPublic/NoneData';
import Attachments from '../Upload/attachment';
import QuillForEditor from '../quillForEditor';
+import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html'
const TextArea = Input.TextArea;
-
+const options = [
+ ['bold', 'italic', 'underline'],
+ [{header: [1,2,3,false]}],
+ ['blockquote', 'code-block'],
+ ['link', 'image'],
+ ['formula']
+];
class Detail extends Component{
constructor(props){
@@ -33,7 +40,9 @@ class Detail extends Component{
page:1,
search_count:undefined,
isSpin:false,
- showFiles: true
+ showFiles: true,
+ quillValue:'',
+ quillFlag:false
}
}
@@ -75,12 +84,26 @@ class Detail extends Component{
//添加评论
addjournals=()=>{
+ const { quillValue } = this.state;
+ if(!quillValue){
+ this.setState({
+ quillFlag:true
+ })
+ return;
+ }
+ let _html = '';
+ try {
+ _html = new QuillDeltaToHtmlConverter(quillValue.ops, {}).convert();
+ } catch (error) {
+ console.log(error);
+ }
this.props.form.validateFieldsAndScroll((err, values) => {
if(!err){
const { data, page, limit, fileList } = this.state;
const url = `/issues/${data.id}/journals.json`;
axios.post(url,{
...values,
+ content:_html,
issue_id:data.id,
attachment_ids:fileList
}).then(result=>{
@@ -89,7 +112,8 @@ class Detail extends Component{
content: ""
});
this.setState({
- showFiles: false
+ showFiles: false,
+ quillValue:''
})
this.getjournalslist(page, limit);
this.props.showNotification("评论成功!");
@@ -216,7 +240,7 @@ class Detail extends Component{
}
renderJournalList=(list)=>{
- console.log(list);
+ // console.log(list);
if(list && list.length >0){
return(
list.map((item,key)=>{
@@ -281,10 +305,16 @@ class Detail extends Component{
showFiles:flag
})
}
+ onContentChange=(value)=>{
+
+ this.setState({
+ quillValue:value
+ })
+ }
render(){
const { projectsId,orderId} = this.props.match.params;
- const { data,journalsdata, page, limit, search_count, isSpin, isedit, showFiles } = this.state;
+ const { data,journalsdata, page, limit, search_count, isSpin, isedit, showFiles , quillValue , quillFlag } = this.state;
const { getFieldDecorator } = this.props.form;
const { current_user } = this.props;
const Paginations = (
@@ -326,7 +356,10 @@ class Detail extends Component{
{
item.content ?
-
{item.content}
+
:
{this.renderJournalList(item.journal_details)}
@@ -371,6 +404,8 @@ class Detail extends Component{
}
}
+
+
return(
@@ -436,28 +471,26 @@ class Detail extends Component{
-
- {getFieldDecorator('content', {
- rules: [{
- required: true, message: '请输入内容'
- }],
- })(
-
- )}
-
+
+
+
+ { quillFlag && 请输入评论内容}
+
+
评论
diff --git a/public/react/src/forge/Order/New.js b/public/react/src/forge/Order/New.js
index 64c1f48c5..6f5c9b4de 100644
--- a/public/react/src/forge/Order/New.js
+++ b/public/react/src/forge/Order/New.js
@@ -12,22 +12,8 @@ import axios from 'axios';
const Option = Select.Option;
const TextArea = Input.TextArea;
-{/* */}
+
+
class New extends Component{
constructor(props){
super(props);
diff --git a/public/react/src/forge/Order/order.css b/public/react/src/forge/Order/order.css
index 1a6c8f508..52d524918 100644
--- a/public/react/src/forge/Order/order.css
+++ b/public/react/src/forge/Order/order.css
@@ -6,7 +6,18 @@
border-bottom: 1px solid #EEEEEE;
flex-wrap: wrap;
}
-
+.quillContent{
+ position: relative;
+ margin-bottom: 4px;
+}
+.quillFlag{
+ position: absolute;
+ bottom:0px;
+ left:6px;
+ height: 20px;
+ line-height: 18px;
+ color: red;
+}
.topmilepost{
padding: 20px 0;
box-sizing: border-box;
@@ -354,9 +365,9 @@
width: 80%;
padding-left: 80px;
}
-.detail_ptitlecount{
+/* .detail_ptitlecount{
padding: 15px;
-}
+} */
.tagList > div:last-child{
border-bottom: none;
diff --git a/public/react/src/forge/quillForEditor/index.js b/public/react/src/forge/quillForEditor/index.js
index 012743141..ea7167249 100644
--- a/public/react/src/forge/quillForEditor/index.js
+++ b/public/react/src/forge/quillForEditor/index.js
@@ -177,7 +177,7 @@ function QuillForEditor ({
const result = await fetchUploadImage(formData);
// 获取上传图片的url
if (result.data && result.data.id) {
- fileUrl = getImageUrl(`api/attachments/${result.data.id}`);
+ fileUrl = `http://123.59.135.93:56666/api/attachments/${result.data.id}`;
}
// 根据id获取文件路径
const { width, height } = imgAttrs;
diff --git a/public/react/src/forge/quillForEditor/index.scss b/public/react/src/forge/quillForEditor/index.scss
index dd4eb0349..c4181433f 100644
--- a/public/react/src/forge/quillForEditor/index.scss
+++ b/public/react/src/forge/quillForEditor/index.scss
@@ -14,6 +14,9 @@
content: '12px';
font-size: 12px;
}
+ .ql-toolbar.ql-snow{
+ padding:0px 8px;
+ }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="14px"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="14px"]::before {
content: '14px';