dev01 1 gadu atpakaļ
vecāks
revīzija
868317a3cf

+ 357 - 290
js/component/administration/business/firmList.jsx

@@ -25,7 +25,7 @@ import {
 } from "@/tools.js";
 import Editors from "@/richTextEditors";
 import SpinContainer from "../../SpinContainer";
-import {companyList, getCompanyName, getCompanyValueArray} from "../../common/configure"; //富文本编辑器
+import { companyList, getCompanyName, getCompanyValueArray } from "../../common/configure"; //富文本编辑器
 
 // 上传文件
 const PicturesWall = React.createClass({
@@ -60,6 +60,42 @@ const PicturesWall = React.createClass({
       fileList: nextProps.pictureUrl
     })
   },
+  // 删除绑定的图片
+  async onRemove(info) {
+    const { id, } = this.props
+    let name = info.response.data
+    let remove = new Promise(function (resolve, reject) {
+      Modal.confirm({
+        title: '操作确认',
+        content: '是否确认删除?',
+        okText: '确定',
+        cancelText: '取消',
+        onOk() {
+          $.ajax({
+            method: "post",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + '/api/admin/news/deleteFile',
+            data: {
+              id, // 新闻id
+              fileName: name
+            }
+          }).done(function (data) {
+            if (!data.error.length) {
+              resolve(true);
+            } else {
+
+            };
+          }.bind(this));
+        },
+        onCancel() {
+          resolve(false)
+        },
+      })
+    });
+    return await remove;
+  },
+
   render() {
     const { previewVisible, previewImage, fileList } = this.state;
     // 点击上传
@@ -76,11 +112,12 @@ const PicturesWall = React.createClass({
           beforeUpload={beforeUploadFile}
           // action={globalConfig.context + "/api/admin/militaryEnterprises/uploadPicture"}
           action={globalConfig.context + "/api/admin/news/uploadFile"}
-          data={{ sign: "enterprises_pucture" }}
+          data={{ id: this.props.id, sign: "enterprises_pucture" }}
           listType="picture-card"
           fileList={fileList}
           onPreview={this.handlePreview}
           onChange={this.handleChange}
+          onRemove={this.onRemove}
         >
           {fileList && fileList.length >= 1 ? null : uploadButton}
         </Upload>
@@ -120,7 +157,7 @@ const FirmList = Form.create()(
           title: this.state.titleSearch,
           location: this.state.locationSearch,
         },
-        success: function(data) {
+        success: function (data) {
           let theArr = [];
           if (!data.data || !data.data.list) {
             if (data.error && data.error.length) {
@@ -141,7 +178,7 @@ const FirmList = Form.create()(
           });
         }.bind(this)
       }).always(
-        function() {
+        function () {
           this.setState({
             loading: false
           });
@@ -151,6 +188,7 @@ const FirmList = Form.create()(
     //声明状态
     getInitialState() {
       return {
+        step: 0,
         loading: false,
         flag: true,
         editorState: null,
@@ -170,13 +208,13 @@ const FirmList = Form.create()(
           defaultPageSize: 10,
           showQuickJumper: true,
           pageSize: 10,
-          onChange: function(page) {
+          onChange: function (page) {
             this.loadData(page);
             this.setState({
               selectedRowKeys: []
             });
           }.bind(this),
-          showTotal: function(total) {
+          showTotal: function (total) {
             return "共" + total + "条数据";
           }
         },
@@ -251,23 +289,23 @@ const FirmList = Form.create()(
             title: "公司",
             dataIndex: "locations",
             key: "locations",
-            width:150,
+            width: 150,
             render: r => {
               let text = '';
-              r && r.map((v,i)=>(
-                  text += (i === 0 ? '':',')+getCompanyName(v)
+              r && r.map((v, i) => (
+                text += (i === 0 ? '' : ',') + getCompanyName(v)
               ))
-              return(
-                  <Tooltip placement="top" title={text}>
-                    {
-                      r && r.map((v,i)=>(
-                          i <= 2 ? (i === 0 ? '':',')+getCompanyName(v) : null
-                      ))
-                    }
-                    {
-                      r.length > 3 ? '.....' : null
-                    }
-                  </Tooltip>
+              return (
+                <Tooltip placement="top" title={text}>
+                  {
+                    r && r.map((v, i) => (
+                      i <= 2 ? (i === 0 ? '' : ',') + getCompanyName(v) : null
+                    ))
+                  }
+                  {
+                    r.length > 3 ? '.....' : null
+                  }
+                </Tooltip>
               )
             }
           },
@@ -358,6 +396,47 @@ const FirmList = Form.create()(
         flag: false
       });
     },
+
+    nextStep() {
+      if (!this.state.locations || this.state.locations.length === 0) {
+        message.warning('请选择公司');
+        return;
+      }
+      $.ajax({
+        method: "post",
+        dataType: "json",
+        crossDomain: false,
+        url: globalConfig.context + "/api/admin/news/addNews",
+        data: {
+          title: this.state.title, // 新闻标题
+          publisher: this.state.publisher, // 新闻发布人
+          type: this.state.type, // 新闻分类
+          sort: this.state.sort, // 
+          locations: this.state.locations.join(','), // 发布公司
+          releaseStatus: 0, // 保存
+          status: 0,
+          releaseTimes: this.state.time
+        },
+        success: function (data) {
+          if (data.error && data.error.length) {
+            message.warning(data.error[0].message);
+          } else {
+            // message.success('操作成功');
+            this.setState({
+              step: 1,
+              id: data.data.id,
+            })
+          }
+        }.bind(this)
+      }).always(
+        function () {
+          this.setState({
+            loading: false
+          });
+        }.bind(this)
+      );
+    },
+
     // 推荐置顶
     toTop(record, num) {
       $.ajax({
@@ -369,7 +448,7 @@ const FirmList = Form.create()(
           id: record.id,
           status: num
         },
-        success: function(data) {
+        success: function (data) {
           let theArr = [];
           if (data.error && data.error.length) {
             message.warning(data.error[0].message);
@@ -378,7 +457,7 @@ const FirmList = Form.create()(
           }
         }.bind(this)
       }).always(
-        function() {
+        function () {
           this.setState({
             loading: false
           });
@@ -390,7 +469,7 @@ const FirmList = Form.create()(
       this.setState({
         editvisible: true,
         flag: true,
-      },()=>{
+      }, () => {
         this.edit(record);
       });
     },
@@ -407,7 +486,7 @@ const FirmList = Form.create()(
         data: {
           id: record.id
         },
-        success: function(data) {
+        success: function (data) {
           let theArr = [];
           if (data.error && data.error.length) {
             message.warning(data.error[0].message);
@@ -420,13 +499,13 @@ const FirmList = Form.create()(
               type: thisdata.type,
               pictureUrl: thisdata.pictureUrl
                 ? splitUrl(
-                    thisdata.pictureUrl,
-                    ",",
-                    globalConfig.avatarUploadHost
-                  )
+                  thisdata.pictureUrl,
+                  ",",
+                  globalConfig.avatarUploadHost
+                )
                 : [],
               sort: thisdata.sort,
-              checked:thisdata.locations.length === companyList.length,
+              checked: thisdata.locations.length === companyList.length,
               indeterminate: thisdata.locations.length < companyList.length,
               locations: thisdata.locations,
               editorcontext: thisdata.content,
@@ -441,7 +520,7 @@ const FirmList = Form.create()(
           }
         }.bind(this)
       }).always(
-        function() {
+        function () {
           this.setState({
             loading: false
           });
@@ -453,87 +532,51 @@ const FirmList = Form.create()(
     },
     // 新增新闻
     addNew(flag) {
-      if(!this.state.locations || this.state.locations.length === 0 ){
+      if (!this.state.locations || this.state.locations.length === 0) {
         message.warning('请选择公司');
-        return ;
+        return;
       }
-      if(!this.state.pictureUrl || this.state.pictureUrl.length === 0){
+      if (!this.state.pictureUrl || this.state.pictureUrl.length === 0) {
         message.warning('请选择新闻大图');
-        return ;
-      }
-      if (this.state.flag) {
-        $.ajax({
-          method: "post",
-          dataType: "json",
-          crossDomain: false,
-          url: globalConfig.context + "/api/admin/news/updateNews",
-          data: {
-            id: this.state.id,
-            title: this.state.title,
-            publisher: this.state.publisher,
-            type: this.state.type,
-            pictureUrl: this.state.pictureUrl && this.state.pictureUrl[0]
-              ? this.state.pictureUrl[0].response.data
-              : undefined,
-            sort: this.state.sort,
-            locations: this.state.locations.join(','),
-            content: this.state.editorcontext,
-            status: this.state.status,
-            releaseTimes: this.state.time,
-            releaseStatus: flag
-          },
-          success: function(data) {
-            let theArr = [];
-            if (data.error && data.error.length) {
-              message.warning(data.error[0].message);
-            } else {
-              message.success('操作成功');
-              this.loadData();
-              this.handleCancelEdit();
-            }
-          }.bind(this)
-        }).always(
-          function() {
-            this.setState({
-              loading: false
-            });
-          }.bind(this)
-        );
-      } else {
-        $.ajax({
-          method: "post",
-          dataType: "json",
-          crossDomain: false,
-          url: globalConfig.context + "/api/admin/news/addNews",
-          data: {
-            title: this.state.title,
-            publisher: this.state.publisher,
-            type: this.state.type,
-            pictureUrl: this.state.pictureUrl[0].response.data,
-            sort: this.state.sort,
-            locations: this.state.locations.join(','),
-            content: this.state.editorcontext,
-            releaseStatus: flag,
-            status: 0,
-            releaseTimes: this.state.time
-          },
-          success: function(data) {
-            if (data.error && data.error.length) {
-              message.warning(data.error[0].message);
-            } else {
-              message.success('操作成功');
-              this.loadData();
-              this.handleCancelEdit();
-            }
-          }.bind(this)
-        }).always(
-          function() {
-            this.setState({
-              loading: false
-            });
-          }.bind(this)
-        );
+        return;
       }
+      $.ajax({
+        method: "post",
+        dataType: "json",
+        crossDomain: false,
+        url: globalConfig.context + "/api/admin/news/updateNews",
+        data: {
+          id: this.state.id,
+          title: this.state.title,
+          publisher: this.state.publisher,
+          type: this.state.type,
+          pictureUrl: this.state.pictureUrl && this.state.pictureUrl[0]
+            ? this.state.pictureUrl[0].response.data
+            : undefined,
+          sort: this.state.sort,
+          locations: this.state.locations.join(','),
+          content: this.state.editorcontext,
+          status: this.state.status,
+          releaseTimes: this.state.time,
+          releaseStatus: flag
+        },
+        success: function (data) {
+          let theArr = [];
+          if (data.error && data.error.length) {
+            message.warning(data.error[0].message);
+          } else {
+            message.success('操作成功');
+            this.loadData();
+            this.handleCancelEdit();
+          }
+        }.bind(this)
+      }).always(
+        function () {
+          this.setState({
+            loading: false
+          });
+        }.bind(this)
+      );
     },
     //表单内容改变时候触发
     change(key, e, f) {
@@ -579,7 +622,7 @@ const FirmList = Form.create()(
         data: {
           id
         },
-        success: function(data) {
+        success: function (data) {
           let theArr = [];
           if (data.error && data.error.length) {
             message.warning(data.error[0].message);
@@ -588,7 +631,7 @@ const FirmList = Form.create()(
           }
         }.bind(this)
       }).always(
-        function() {
+        function () {
           this.setState({
             loading: false
           });
@@ -622,7 +665,7 @@ const FirmList = Form.create()(
         editorcontext: "",
         time: undefined,
         indeterminate: false,
-        checked:false,
+        checked: false,
       });
     },
     //搜索部分的清零
@@ -630,7 +673,7 @@ const FirmList = Form.create()(
       this.setState({
         locationSearch: '',
         titleSearch: undefined,
-      },()=>{
+      }, () => {
         this.loadData();
       })
     },
@@ -669,18 +712,18 @@ const FirmList = Form.create()(
                 }}
               />
               <Select
-                  placeholder="请选择公司"
-                  style={{ width: 150 }}
-                  value={this.state.locationSearch}
-                  onChange={e => {
-                    this.setState({
-                      locationSearch: e
-                    });
-                  }}
+                placeholder="请选择公司"
+                style={{ width: 150 }}
+                value={this.state.locationSearch}
+                onChange={e => {
+                  this.setState({
+                    locationSearch: e
+                  });
+                }}
               >
                 {
-                  companyList.map((v)=>(
-                      <Select.Option key={v.value} value={v.value}>{v.label}</Select.Option>
+                  companyList.map((v) => (
+                    <Select.Option key={v.value} value={v.value}>{v.label}</Select.Option>
                   ))
                 }
               </Select>
@@ -725,195 +768,219 @@ const FirmList = Form.create()(
               className="customeDetails"
               title={this.state.flag ? "新闻详情" : "新增新闻"}
               width="1000px"
+              maskClosable={false}
               onCancel={this.handleCancelEdit}
               visible={this.state.editvisible}
               footer=""
             >
-                <SpinContainer spinning={this.state.loading}>
-                  <div className="clearfix">
-                    <FormItem
-                      className="half-item"
-                      labelCol={{ span: 8 }}
-                      wrapperCol={{ span: 12 }}
-                      label="新闻标题"
-                    >
-                      <Input
-                        placeholder="请输入新闻标题"
-                        value={this.state.title}
-                        onChange={e => {
-                          this.setState({
-                            title: e.target.value
-                          });
-                        }}
-                        style={{ width: "240px" }}
-                      />
-                    </FormItem>
-                    <FormItem
-                      className="half-item"
-                      labelCol={{ span: 8 }}
-                      wrapperCol={{ span: 12 }}
-                      label="新闻类别"
-                    >
-                      <Select
-                        style={{ width: 120 }}
-                        placeholder="请选择新闻类型"
-                        value={
-                          this.state.type == 1
-                            ? "行业新闻"
-                            : this.state.type == 0
+              <SpinContainer spinning={this.state.loading}>
+                <div className="clearfix">
+                  <FormItem
+                    className="half-item"
+                    labelCol={{ span: 8 }}
+                    wrapperCol={{ span: 12 }}
+                    label="新闻标题"
+                  >
+                    <Input
+                      placeholder="请输入新闻标题"
+                      value={this.state.title}
+                      onChange={e => {
+                        this.setState({
+                          title: e.target.value
+                        });
+                      }}
+                      style={{ width: "240px" }}
+                    />
+                  </FormItem>
+                  <FormItem
+                    className="half-item"
+                    labelCol={{ span: 8 }}
+                    wrapperCol={{ span: 12 }}
+                    label="新闻类别"
+                  >
+                    <Select
+                      style={{ width: 120 }}
+                      placeholder="请选择新闻类型"
+                      value={
+                        this.state.type == 1
+                          ? "行业新闻"
+                          : this.state.type == 0
                             ? "公司新闻"
                             : []
-                        }
-                        onChange={e => {
-                          this.setState({
-                            type: e
-                          });
-                        }}
-                      >
-                        <Option value="0">公司新闻</Option>
-                        <Option value="1">行业新闻</Option>
-                      </Select>
-                    </FormItem>
-                    <FormItem
-                      className="half-item"
-                      labelCol={{ span: 8 }}
-                      wrapperCol={{ span: 12 }}
-                      label="新闻发布人"
-                    >
-                      <Input
-                        placeholder="请输入新闻发布人"
-                        value={this.state.publisher}
-                        onChange={e => {
-                          this.setState({
-                            publisher: e.target.value
-                          });
-                        }}
-                        style={{ width: "240px" }}
-                      />
-                    </FormItem>
-                    <FormItem
-                      className="half-item"
-                      labelCol={{ span: 8 }}
-                      wrapperCol={{ span: 12 }}
-                      label="发布时间"
-                    >
-                      <DatePicker
-                        placeholder="请输入发布时间"
-                        format="YYYY-MM-DD HH:mm:ss"
-                        showTime
-                        value={this.state.time ? moment(this.state.time) : null}
-                        onChange={(e, f) => {
-                          this.setState({ time: f });
-                          console.log(e, f);
-                        }}
-                        style={{ width: "240px" }}
-                      />
-                    </FormItem>
-                    <FormItem
-                      className="half-item"
-                      labelCol={{ span: 8 }}
-                      wrapperCol={{ span: 12 }}
-                      label="排序"
-                    >
-                      <Input
-                        placeholder="请输入排序"
-                        value={this.state.sort}
-                        onChange={e => {
-                          this.setState({
-                            sort: e.target.value
-                          });
-                        }}
-                        style={{ width: "240px" }}
-                      />
-                    </FormItem>
-                    <FormItem
-                        className="half-item"
-                        labelCol={{ span: 8 }}
-                        wrapperCol={{ span: 12 }}
-                        label="公司"
-                    >
-                      <Checkbox indeterminate={this.state.indeterminate} checked={this.state.checked} onChange={(e)=>{
+                      }
+                      onChange={e => {
                         this.setState({
-                          locations: e.target.checked ? getCompanyValueArray():[],
-                          indeterminate: false,
-                          checked:e.target.checked
-                        })
-                      }}>全选</Checkbox>
-                      <Checkbox.Group
-                          options={companyList}
-                          value={this.state.locations}
-                          onChange={(e) => {
-                            this.setState({
-                              locations: e,
-                              indeterminate: companyList.length > e.length,
-                              checked: companyList.length === e.length
-                            });
-                          }}
-                      />
-                    </FormItem>
-                  </div>
-                  <div className="clearfix">
-                    <FormItem
-                      labelCol={{ span: 4 }}
-                      wrapperCol={{ span: 18 }}
-                      onCancel={this.handleCancel}
-                      label="新闻大图"
-                    >
-                      <PicturesWall
-                        fileList={this.getOrgCodeUrl}
-                        pictureUrl={this.state.pictureUrl}
-                      />
-                      <p>建议尺寸:345X200 图片建议:要清晰。</p>
-                    </FormItem>
-                  </div>
-                  <div className="clearfix">
-                    <FormItem
-                      labelCol={{ span: 4 }}
-                      wrapperCol={{ span: 18 }}
-                      label="企业简介"
+                          type: e
+                        });
+                      }}
                     >
-                      <Editors
-                        textContent={this.state.editorcontext}
-                        uploadUrl={"/api/admin/news/uploadFile"}
-                        globalConfig={globalConfig.uploadPath}
-                        placeholder="业务项目客户基本条件"
-                        handleRichText={value => {
-                          this.setState({ editorcontext: value });
-                        }}
-                      />
-                    </FormItem>
-                  </div>
-                  <div className="clearfix">
-                    <Button
-                      type="primary"
-                      size="large"
-                      onClick={e => {
-                        this.addNew(0);
+                      <Option value="0">公司新闻</Option>
+                      <Option value="1">行业新闻</Option>
+                    </Select>
+                  </FormItem>
+                  <FormItem
+                    className="half-item"
+                    labelCol={{ span: 8 }}
+                    wrapperCol={{ span: 12 }}
+                    label="新闻发布人"
+                  >
+                    <Input
+                      placeholder="请输入新闻发布人"
+                      value={this.state.publisher}
+                      onChange={e => {
+                        this.setState({
+                          publisher: e.target.value
+                        });
                       }}
-                      style={{
-                        float: "right",
-                        marginRight: "80px",
-                        marginTop: "20px"
+                      style={{ width: "240px" }}
+                    />
+                  </FormItem>
+                  <FormItem
+                    className="half-item"
+                    labelCol={{ span: 8 }}
+                    wrapperCol={{ span: 12 }}
+                    label="发布时间"
+                  >
+                    <DatePicker
+                      placeholder="请输入发布时间"
+                      format="YYYY-MM-DD HH:mm:ss"
+                      showTime
+                      value={this.state.time ? moment(this.state.time) : null}
+                      onChange={(e, f) => {
+                        this.setState({ time: f });
                       }}
-                    >
-                      保存
-                    </Button>
+                      style={{ width: "240px" }}
+                    />
+                  </FormItem>
+                  <FormItem
+                    className="half-item"
+                    labelCol={{ span: 8 }}
+                    wrapperCol={{ span: 12 }}
+                    label="排序"
+                  >
+                    <Input
+                      placeholder="请输入排序"
+                      value={this.state.sort}
+                      onChange={e => {
+                        this.setState({
+                          sort: e.target.value
+                        });
+                      }}
+                      style={{ width: "240px" }}
+                    />
+                  </FormItem>
+                  <FormItem
+                    className="half-item"
+                    labelCol={{ span: 8 }}
+                    wrapperCol={{ span: 12 }}
+                    label="公司"
+                  >
+                    <Checkbox indeterminate={this.state.indeterminate} checked={this.state.checked} onChange={(e) => {
+                      this.setState({
+                        locations: e.target.checked ? getCompanyValueArray() : [],
+                        indeterminate: false,
+                        checked: e.target.checked
+                      })
+                    }}>全选</Checkbox>
+                    <Checkbox.Group
+                      options={companyList}
+                      value={this.state.locations}
+                      onChange={(e) => {
+                        this.setState({
+                          locations: e,
+                          indeterminate: companyList.length > e.length,
+                          checked: companyList.length === e.length
+                        });
+                      }}
+                    />
+                  </FormItem>
+                </div>
+                {
+                  !this.state.flag && this.state.step == 0 &&
+                  <div className="clearfix" style={{ display: "flex", justifyContent: "center" }}>
                     <Button
                       type="primary"
                       size="large"
                       onClick={e => {
-                        this.addNew(1);
+                        this.nextStep(0);
                       }}
                       style={{
-                        float: "right",
-                        marginRight: "20px",
-                        marginTop: "20px"
+                        margin: "20px auto"
                       }}
                     >
-                      保存并发布
+                      下一步
                     </Button>
                   </div>
-                </SpinContainer>
+                }
+                {
+                  ((!this.state.flag && this.state.step == 1) || this.state.flag) &&
+                  <div>
+                    <div className="clearfix">
+                      <FormItem
+                        labelCol={{ span: 4 }}
+                        wrapperCol={{ span: 18 }}
+                        onCancel={this.handleCancel}
+                        label="新闻大图"
+                      >
+                        <PicturesWall
+                          id={this.state.id}
+                          fileList={this.getOrgCodeUrl}
+                          pictureUrl={this.state.pictureUrl}
+                        />
+                        <p>建议尺寸:345X200 图片建议:要清晰。</p>
+                      </FormItem>
+                    </div>
+                    <div className="clearfix">
+                      <FormItem
+                        labelCol={{ span: 4 }}
+                        wrapperCol={{ span: 18 }}
+                        label="企业简介"
+                      >
+                        <Editors
+                          textContent={this.state.editorcontext}
+                          uploadUrl={"/api/admin/news/uploadFile"}
+                          uploadId={this.state.id}
+                          globalConfig={globalConfig.uploadPath}
+                          placeholder="业务项目客户基本条件"
+                          handleRichText={value => {
+                            this.setState({ editorcontext: value });
+                          }}
+                        />
+                      </FormItem>
+                    </div>
+                    <div className="clearfix">
+                      <Button
+                        type="primary"
+                        size="large"
+                        onClick={e => {
+                          this.addNew(0);
+                        }}
+                        style={{
+                          float: "right",
+                          marginRight: "80px",
+                          marginTop: "20px"
+                        }}
+                      >
+                        保存
+                      </Button>
+                      <Button
+                        type="primary"
+                        size="large"
+                        onClick={e => {
+                          this.addNew(1);
+                        }}
+                        style={{
+                          float: "right",
+                          marginRight: "20px",
+                          marginTop: "20px"
+                        }}
+                      >
+                        保存并发布
+                      </Button>
+                    </div>
+                  </div>
+                }
+              </SpinContainer>
             </Modal>
             <Modal
               visible={this.state.imgeditvisible}

+ 228 - 224
js/component/richTextEditors.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 import theme from 'react-quill/dist/quill.snow.css';
 import { message } from 'antd';
-import ReactQuill,{Quill} from 'react-quill';
+import ReactQuill, { Quill } from 'react-quill';
 import ajax from 'jquery/src/ajax/xhr.js';
 import $ from 'jquery/src/ajax';
 import audioIcon from '../../image/audio.png';
@@ -9,26 +9,26 @@ import audioIcon from '../../image/audio.png';
 
 let BlockEmbed = Quill.import('blots/block/embed');
 class AppPanelEmbed extends BlockEmbed {
-    static create(value) {
-        const node = super.create(value);
-        node.setAttribute('contenteditable', 'false');
-        node.setAttribute('width', '100%');
-        //   设置自定义html
-        node.innerHTML = this.transformValue(value)
-        return node;
-    }
+  static create(value) {
+    const node = super.create(value);
+    node.setAttribute('contenteditable', 'false');
+    node.setAttribute('width', '100%');
+    //   设置自定义html
+    node.innerHTML = this.transformValue(value)
+    return node;
+  }
 
-    static transformValue(value) {
-        let handleArr = value.split('\n')
-        handleArr = handleArr.map(e => e.replace(/^[\s]+/, '')
-            .replace(/[\s]+$/, ''))
-        return handleArr.join('')
-    }
+  static transformValue(value) {
+    let handleArr = value.split('\n')
+    handleArr = handleArr.map(e => e.replace(/^[\s]+/, '')
+      .replace(/[\s]+$/, ''))
+    return handleArr.join('')
+  }
 
-    // 返回节点自身的value值 用于撤销操作
-    static value(node) {
-        return node.innerHTML
-    }
+  // 返回节点自身的value值 用于撤销操作
+  static value(node) {
+    return node.innerHTML
+  }
 }
 // blotName
 AppPanelEmbed.blotName = 'AppPanelEmbed';
@@ -38,236 +38,240 @@ AppPanelEmbed.className = 'embed-innerApp';
 AppPanelEmbed.tagName = 'p';
 Quill.register(AppPanelEmbed);
 
-var RichTextUploadUrl, RichTextUploadSign;
+var RichTextUploadUrl, RichTextUploadSign, RichTextUploadId;
 //上传图片
-function uploadImg(s,_this) {
-    let myform = new FormData()
-    let file = document.getElementById(_this.props.id + "fileToUpload").files[0];
-    if (!file) { return; };
-    if(file.size > 52428800){
-        message.warning('图片大小不能超过50M');
-        return
+function uploadImg(s, _this) {
+  let myform = new FormData()
+  let file = document.getElementById(_this.props.id + "fileToUpload").files[0];
+  if (!file) { return; };
+  if (file.size > 52428800) {
+    message.warning('图片大小不能超过50M');
+    return
+  }
+  myform.append('file', file);
+  myform.append('sign', RichTextUploadSign);
+  myform.append('id', RichTextUploadId);
+  $.ajax({
+    method: "post",
+    dataType: "json",
+    url: location.origin + RichTextUploadUrl,
+    data: myform,
+    contentType: false,
+    processData: false,
+    success: function (data) {
+      if (data.error && data.error.length) {
+        message.warning(data.error[0].message);
+        document.getElementById(_this.props.id + "fileToUpload").value = ''
+      } else {
+        const cursorPosition = s.quill.getSelection().index
+        s.quill.insertEmbed(
+          cursorPosition,
+          'AppPanelEmbed',
+          `<img style="width: 100%" src="${globalConfig.avatarUploadHost + data.data}"/>`
+        );
+        s.quill.setSelection(cursorPosition + 1);
+        document.getElementById(_this.props.id + "fileToUpload").value = ''
+      };
+    },
+    error: function (XMLHttpRequest, textStatus, errorThrown) {
+      //查看错误信息
+      message("上传失败");
+      document.getElementById(_this.props.id + "fileToUpload").value = ''
     }
-    myform.append('file', file);
-    myform.append('sign', RichTextUploadSign);
-    $.ajax({
-        method: "post",
-        dataType: "json",
-        url: location.origin + RichTextUploadUrl,
-        data: myform,
-        contentType: false,
-        processData: false,
-        success: function (data) {
-            if (data.error && data.error.length) {
-                message.warning(data.error[0].message);
-                document.getElementById(_this.props.id + "fileToUpload").value = ''
-            } else {
-                const cursorPosition = s.quill.getSelection().index
-                s.quill.insertEmbed(
-                    cursorPosition,
-                    'AppPanelEmbed',
-                    `<img style="width: 100%" src="${globalConfig.avatarUploadHost + data.data}"/>`
-                );
-                s.quill.setSelection(cursorPosition + 1);
-                document.getElementById(_this.props.id + "fileToUpload").value = ''
-            };
-        },
-        error: function(XMLHttpRequest, textStatus, errorThrown){
-            //查看错误信息
-            message("上传失败");
-            document.getElementById(_this.props.id + "fileToUpload").value = ''
-        }
-    })
+  })
 }
 //图片文件选择
 function fileSelect() {
-    let _this = this.options._this;
-    let uploader = document.getElementById(_this.props.id + "fileToUpload");
-    if (!uploader.onchange) {
-        uploader.onchange = () => {
-            uploadImg(this,_this)
-        }
+  let _this = this.options._this;
+  let uploader = document.getElementById(_this.props.id + "fileToUpload");
+  if (!uploader.onchange) {
+    uploader.onchange = () => {
+      uploadImg(this, _this)
     }
-    uploader.click();
+  }
+  uploader.click();
 }
 //音频文件选择
 function fileSelectAudio() {
-    let _this = this.options._this;
-    let uploader = document.getElementById(_this.props.id + "fileToUploadAudio");
-    if (!uploader.onchange) {
-        uploader.onchange = () => {
-            uploadAudio(this,_this)
-        }
+  let _this = this.options._this;
+  let uploader = document.getElementById(_this.props.id + "fileToUploadAudio");
+  if (!uploader.onchange) {
+    uploader.onchange = () => {
+      uploadAudio(this, _this)
     }
-    uploader.click();
+  }
+  uploader.click();
 }
 //音频文件上传
-function uploadAudio(s,_this) {
-    let myform = new FormData()
-    let file = document.getElementById(_this.props.id + "fileToUploadAudio").files[0]
-    if (!file) { return; };
-    if(file.size > 52428800){
-        message.warning('音频大小不能超过50M');
-        return
-    }
-    myform.append('file', file);
-    myform.append('sign', RichTextUploadSign);
-    $.ajax({
-        method: "post",
-        dataType: "json",
-        url: location.origin + RichTextUploadUrl,
-        data: myform,
-        contentType: false,
-        processData: false,
-        success: function (data) {
-            if (data.error && data.error.length) {
-                message.warning(data.error[0].message);
-                document.getElementById(_this.props.id + "fileToUploadAudio").value = ''
-            } else {
-                const cursorPosition = s.quill.getSelection().index
-                s.quill.insertEmbed(
-                    cursorPosition,
-                    'AppPanelEmbed',
-                    `<audio src="${globalConfig.avatarUploadHost + data.data}" controls="controls">Your browser does not support the audio element.</audio>`
-                );
-                s.quill.setSelection(cursorPosition + 1)
-                document.getElementById(_this.props.id + "fileToUploadAudio").value = ''
-            };
+function uploadAudio(s, _this) {
+  let myform = new FormData()
+  let file = document.getElementById(_this.props.id + "fileToUploadAudio").files[0]
+  if (!file) { return; };
+  if (file.size > 52428800) {
+    message.warning('音频大小不能超过50M');
+    return
+  }
+  myform.append('file', file);
+  myform.append('sign', RichTextUploadSign);
+  myform.append('id', RichTextUploadId);
+  $.ajax({
+    method: "post",
+    dataType: "json",
+    url: location.origin + RichTextUploadUrl,
+    data: myform,
+    contentType: false,
+    processData: false,
+    success: function (data) {
+      if (data.error && data.error.length) {
+        message.warning(data.error[0].message);
+        document.getElementById(_this.props.id + "fileToUploadAudio").value = ''
+      } else {
+        const cursorPosition = s.quill.getSelection().index
+        s.quill.insertEmbed(
+          cursorPosition,
+          'AppPanelEmbed',
+          `<audio src="${globalConfig.avatarUploadHost + data.data}" controls="controls">Your browser does not support the audio element.</audio>`
+        );
+        s.quill.setSelection(cursorPosition + 1)
+        document.getElementById(_this.props.id + "fileToUploadAudio").value = ''
+      };
 
-        },
-        error: function(XMLHttpRequest, textStatus, errorThrown){
-            document.getElementById(_this.props.id + "fileToUploadAudio").value = ''
-            //查看错误信息
-            message("上传失败");
-        }
-    })
+    },
+    error: function (XMLHttpRequest, textStatus, errorThrown) {
+      document.getElementById(_this.props.id + "fileToUploadAudio").value = ''
+      //查看错误信息
+      message("上传失败");
+    }
+  })
 }
 //视频文件选择
 function fileSelectVideo() {
-    let _this = this.options._this;
-    let uploader = document.getElementById(_this.props.id + "fileToUploadVideo");
-    if (!uploader.onchange) {
-        uploader.onchange = () => {
-            uploadVideo(this,_this)
-        }
+  let _this = this.options._this;
+  let uploader = document.getElementById(_this.props.id + "fileToUploadVideo");
+  if (!uploader.onchange) {
+    uploader.onchange = () => {
+      uploadVideo(this, _this)
     }
-    uploader.click();
+  }
+  uploader.click();
 }
 //视频文件上传
-function uploadVideo(s,_this) {
-    let myform = new FormData()
-    let file = document.getElementById(_this.props.id + "fileToUploadVideo").files[0]
-    if (!file) { return; };
-    if(file.size > 52428800){
-        message.warning('视频大小不能超过50M');
-        return
-    }
-    myform.append('file', file);
-    myform.append('sign', RichTextUploadSign);
-    $.ajax({
-        method: "post",
-        dataType: "json",
-        url: location.origin + RichTextUploadUrl,
-        data: myform,
-        contentType: false,
-        processData: false,
-        success: function (data) {
-            if (data.error && data.error.length) {
-                message.warning(data.error[0].message);
-                document.getElementById(_this.props.id + "fileToUploadVideo").value = ''
-            } else {
-                const cursorPosition = s.quill.getSelection().index
-                s.quill.insertEmbed(
-                    cursorPosition,
-                    'AppPanelEmbed',
-                    `<video style="width:100%" controls="" autoPlay="" name="media">
+function uploadVideo(s, _this) {
+  let myform = new FormData()
+  let file = document.getElementById(_this.props.id + "fileToUploadVideo").files[0]
+  if (!file) { return; };
+  if (file.size > 52428800) {
+    message.warning('视频大小不能超过50M');
+    return
+  }
+  myform.append('file', file);
+  myform.append('sign', RichTextUploadSign);
+  myform.append('id', RichTextUploadId);
+  $.ajax({
+    method: "post",
+    dataType: "json",
+    url: location.origin + RichTextUploadUrl,
+    data: myform,
+    contentType: false,
+    processData: false,
+    success: function (data) {
+      if (data.error && data.error.length) {
+        message.warning(data.error[0].message);
+        document.getElementById(_this.props.id + "fileToUploadVideo").value = ''
+      } else {
+        const cursorPosition = s.quill.getSelection().index
+        s.quill.insertEmbed(
+          cursorPosition,
+          'AppPanelEmbed',
+          `<video style="width:100%" controls="" autoPlay="" name="media">
                             <source src=${globalConfig.avatarUploadHost + data.data} type="video/mp4">
                     </video>`
-                );
-                s.quill.setSelection(cursorPosition + 1);
-                document.getElementById(_this.props.id + "fileToUploadVideo").value = ''
-            };
+        );
+        s.quill.setSelection(cursorPosition + 1);
+        document.getElementById(_this.props.id + "fileToUploadVideo").value = ''
+      };
 
-        },
-        error: function(XMLHttpRequest, textStatus, errorThrown){
-            document.getElementById(_this.props.id + "fileToUploadVideo").value = ''
-            //查看错误信息
-        }
-    })
+    },
+    error: function (XMLHttpRequest, textStatus, errorThrown) {
+      document.getElementById(_this.props.id + "fileToUploadVideo").value = ''
+      //查看错误信息
+    }
+  })
 }
 
 const Editors = React.createClass({
-    getInitialState() {
-        return {
-            value: null,
-            theBool: true
-        }
-    },
-    handleRichText(value) {
-        this.setState({ value: value });
-        this.props.handleRichText(value);
-        // this.props.handleRichText(value.replace(/iframe/g, 'video'));
-    },
-    componentDidMount() {
-        document.getElementsByClassName( 'ql-audio')[this.props.id || 0].style = `background: url(${audioIcon}) no-repeat;background-size: contain;`
-    },
-    componentWillMount() {
-        RichTextUploadUrl = this.props.uploadUrl;
-        RichTextUploadSign = this.props.uploadSign;
-    },
-    componentWillReceiveProps(nextProps) {
-        this.state.theBool = true;
-        // if(nextProps.textContent){
-        this.state.value = nextProps.textContent || '';
-        // }
-    },
-    render() {
-        const modules = {
-            toolbar: {
-                container: [
-                    [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
-                    [{ 'header': [1, 2, 3, false] }],
-                    ['bold', 'italic', 'underline', 'strike', 'blockquote'],        // toggled buttons
-                    //  [{ 'header': 1 }, { 'header': 2 }],               // custom button values
-                    [{ 'list': 'ordered' }, { 'list': 'bullet' }],
-                    //  [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
-                    [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
-                    //  [{ 'direction': 'rtl' }],                         // text direction
-                    [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
-                    //  [{ 'font': [] }],
-                    [{ 'align': [] }],
-                    ['link', 'image','video'],
-                    ['clean'],
-                    ['audio'],
-                ],
-                handlers: { 'image': fileSelect ,'video': fileSelectVideo,'audio':fileSelectAudio},
-                _this:this
-            },
-        };
-        const formats = [
-            'size', 'header',
-            'bold', 'italic', 'underline', 'strike', 'blockquote',
-            'list', 'bullet', 'indent',
-            'color', 'background',
-            'align',
-            'link', 'image','video','AppPanelEmbed','clean'
-        ];
-        return (
-            <div>
-                <ReactQuill
-                    theme="snow"
-                    value={this.state.value}
-                    modules={modules}
-                    formats={formats}
-                    placeholder='请填写内容!'
-                    onChange={this.handleRichText}
-                />
-                <input accept="image/*" type="file" name={this.props.id + "fileToUpload"} id={this.props.id + "fileToUpload"} placeholder='请填写内容!' style={{ "display": "none" }} />
-                <input accept="video/*" type="file" name={this.props.id + "fileToUploadVideo"} id={this.props.id + "fileToUploadVideo"} placeholder='请填写视频!' style={{ "display": "none" }} />
-                <input accept="audio/*" type="file" name={this.props.id + "fileToUploadAudio"} id={this.props.id + "fileToUploadAudio"} placeholder='请选择音频!' style={{ "display": "none" }} />
-            </div>
-        )
-    },
+  getInitialState() {
+    return {
+      value: null,
+      theBool: true
+    }
+  },
+  handleRichText(value) {
+    this.setState({ value: value });
+    this.props.handleRichText(value);
+    // this.props.handleRichText(value.replace(/iframe/g, 'video'));
+  },
+  componentDidMount() {
+    document.getElementsByClassName('ql-audio')[this.props.id || 0].style = `background: url(${audioIcon}) no-repeat;background-size: contain;`
+  },
+  componentWillMount() {
+    RichTextUploadUrl = this.props.uploadUrl;
+    RichTextUploadSign = this.props.uploadSign;
+  },
+  componentWillReceiveProps(nextProps) {
+    RichTextUploadId = nextProps.uploadId;
+    this.state.theBool = true;
+    // if(nextProps.textContent){
+    this.state.value = nextProps.textContent || '';
+    // }
+  },
+  render() {
+    const modules = {
+      toolbar: {
+        container: [
+          [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
+          [{ 'header': [1, 2, 3, false] }],
+          ['bold', 'italic', 'underline', 'strike', 'blockquote'],        // toggled buttons
+          //  [{ 'header': 1 }, { 'header': 2 }],               // custom button values
+          [{ 'list': 'ordered' }, { 'list': 'bullet' }],
+          //  [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
+          [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
+          //  [{ 'direction': 'rtl' }],                         // text direction
+          [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
+          //  [{ 'font': [] }],
+          [{ 'align': [] }],
+          ['link', 'image', 'video'],
+          ['clean'],
+          ['audio'],
+        ],
+        handlers: { 'image': fileSelect, 'video': fileSelectVideo, 'audio': fileSelectAudio },
+        _this: this
+      },
+    };
+    const formats = [
+      'size', 'header',
+      'bold', 'italic', 'underline', 'strike', 'blockquote',
+      'list', 'bullet', 'indent',
+      'color', 'background',
+      'align',
+      'link', 'image', 'video', 'AppPanelEmbed', 'clean'
+    ];
+    return (
+      <div>
+        <ReactQuill
+          theme="snow"
+          value={this.state.value}
+          modules={modules}
+          formats={formats}
+          placeholder='请填写内容!'
+          onChange={this.handleRichText}
+        />
+        <input accept="image/*" type="file" name={this.props.id + "fileToUpload"} id={this.props.id + "fileToUpload"} placeholder='请填写内容!' style={{ "display": "none" }} />
+        <input accept="video/*" type="file" name={this.props.id + "fileToUploadVideo"} id={this.props.id + "fileToUploadVideo"} placeholder='请填写视频!' style={{ "display": "none" }} />
+        <input accept="audio/*" type="file" name={this.props.id + "fileToUploadAudio"} id={this.props.id + "fileToUploadAudio"} placeholder='请选择音频!' style={{ "display": "none" }} />
+      </div>
+    )
+  },
 });
 
 export default Editors;

+ 2 - 2
package.json

@@ -1,13 +1,13 @@
 {
   "name": "afanti",
-  "version": "1.0.6",
+  "version": "1.0.8",
   "description": "",
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "dlldev": "webpack --progress --colors --config ./webpack-dll.config.js --env.deploy dev --env.host 'http://127.0.0.1'",
     "dlltest": "webpack --progress --colors --config ./webpack-dll.config.js --env.deploy test --env.host 'http://static.jishutao.com'",
-    "dllpro": "webpack --progress --colors --config ./webpack-dll.config.js --env.deploy prod --env.host 'http://count.jishutao.com'",
+    "dllpro": "webpack --progress --colors --config ./webpack-dll.config.js --env.deploy prod --env.host '//count.jishutao.com'",
     "build": "node bin/clean.js && webpack --progress --colors --env.deploy dev",
     "buildtest": "node --max-old-space-size=8192 bin/clean.js && webpack --progress --colors --env.deploy test",
     "buildstage": "node bin/clean.js && webpack --progress --colors --env.deploy stage",

+ 1 - 1
webpack-dll.config.js

@@ -16,7 +16,7 @@ module.exports = (function () {
             staticHost = 'http://statics.jishutao.com';
             break;
         case 'prod':
-            staticHost = 'http://count.jishutao.com';
+            staticHost = '//count.jishutao.com';
             break;
         default:
             break;

+ 2 - 2
webpack.config.js

@@ -31,7 +31,7 @@ module.exports = (function () {
             jumlApi = 'http://uat.jishutao.com'
             break
         case 'prod':
-            jumlApi = 'http://count.jishutao.com'
+            jumlApi = '//count.jishutao.com'
             break
         default:
             break
@@ -141,7 +141,7 @@ module.exports = (function () {
             staticHost = 'http://static.jishutao.com'
             break
         case 'prod':
-            staticHost = 'http://count.jishutao.com'
+            staticHost = '//count.jishutao.com'
             break
         default:
             break