Quellcode durchsuchen

增加公司选项

HW vor 4 Jahren
Ursprung
Commit
ed62e8a6da

+ 13 - 0
js/component/administration/business/activity/index.jsx

@@ -6,6 +6,7 @@ import {
 } from "@/tools.js";
 import ActivityOperation from './components/activityOperation';
 import SpinContainer from "../../../SpinContainer";
+import {getCompanyName} from "../../../common/configure";
 
 class Activity extends Component{
     constructor(props) {
@@ -78,6 +79,18 @@ class Activity extends Component{
                     }
                 },
                 {
+                    title: "公司",
+                    dataIndex: "locations",
+                    key: "locations",
+                    render: r => {
+                        return(
+                            r && r.map((v)=>(
+                                <Tag>{getCompanyName(v)}</Tag>
+                            ))
+                        )
+                    }
+                },
+                {
                     title: "是否发布",
                     dataIndex: "releaseStatus",
                     key: "releaseStatus",

+ 87 - 33
js/component/administration/business/firmList.jsx

@@ -20,7 +20,7 @@ import {
   Radio,
   TimePicker,
   Tabs,
-  Tag
+  Tag, Checkbox
 } from "antd";
 import { areaSelect, getProvince } from "@/NewDicProvinceList"; //省市区
 import {
@@ -33,7 +33,8 @@ import {
   getPicPath
 } from "@/tools.js";
 import Editors from "@/richTextEditors";
-import SpinContainer from "../../SpinContainer"; //富文本编辑器
+import SpinContainer from "../../SpinContainer";
+import {companyList, getCompanyName, getCompanyValueArray} from "../../common/configure"; //富文本编辑器
 
 // 上传文件
 const PicturesWall = React.createClass({
@@ -41,7 +42,9 @@ const PicturesWall = React.createClass({
     return {
       previewVisible: false,
       previewImage: "",
-      fileList: this.props.pictureUrl
+      fileList: this.props.pictureUrl,
+      locations: [],
+      indeterminate: false,
     };
   },
   getDefaultProps() {
@@ -64,8 +67,6 @@ const PicturesWall = React.createClass({
     this.props.fileList(fileList);
   },
   componentWillReceiveProps(nextProps) {
-    this.state.fileList = nextProps.pictureUrl;
-    console.log(nextProps.pictureUrl);
   },
   render() {
     const { previewVisible, previewImage, fileList } = this.state;
@@ -124,7 +125,8 @@ const FirmList = Form.create()(
         data: {
           pageNo: pageNo || this.state.pagination.current || 1,
           pageSize: this.state.pagination.pageSize,
-          title: this.state.titleSearch
+          title: this.state.titleSearch,
+          location: this.state.locationSearch,
         },
         success: function(data) {
           let theArr = [];
@@ -135,19 +137,8 @@ const FirmList = Form.create()(
           } else {
             for (let i = 0; i < data.data.list.length; i++) {
               let thisdata = data.data.list[i];
-              theArr.push({
-                key: i + 1,
-                id: thisdata.id,
-                title: thisdata.title,
-                publisher: thisdata.publisher,
-                type: thisdata.type,
-                pictureUrl: thisdata.pictureUrl,
-                sort: thisdata.sort,
-                releaseStatus: thisdata.releaseStatus,
-                releaseTimeConvert: thisdata.releaseTimeConvert,
-                status: thisdata.status,
-                content: thisdata.content
-              });
+              thisdata.key = i + 1
+              theArr.push(thisdata);
             }
             this.state.pagination.current = data.data.pageNo;
             this.state.pagination.total = data.data.totalCount;
@@ -263,6 +254,18 @@ const FirmList = Form.create()(
             }
           },
           {
+            title: "公司",
+            dataIndex: "locations",
+            key: "locations",
+            render: r => {
+              return(
+                  r && r.map((v)=>(
+                      <Tag>{getCompanyName(v)}</Tag>
+                  ))
+              )
+            }
+          },
+          {
             title: "发布状态",
             dataIndex: "releaseStatus",
             key: "releaseStatus",
@@ -379,9 +382,11 @@ const FirmList = Form.create()(
     //编辑按钮操作
     tableRowClick(record) {
       this.setState({
-        editvisible: true
+        editvisible: true,
+        flag: true,
+      },()=>{
+        this.edit(record);
       });
-      this.edit(record);
     },
     edit(record, index) {
       this.setState({
@@ -415,6 +420,8 @@ const FirmList = Form.create()(
                   )
                 : [],
               sort: thisdata.sort,
+              indeterminate: thisdata.locations ? thisdata.locations.length === companyList.length : false,
+              locations: thisdata.locations,
               editorcontext: thisdata.content,
               releaseStatus: thisdata.releaseStatus,
               time: thisdata.releaseTimeConvert
@@ -439,6 +446,14 @@ const FirmList = Form.create()(
     },
     // 新增新闻
     addNew(flag) {
+      if(!this.state.locations || this.state.locations.length === 0 ){
+        message.warning('请选择公司');
+        return ;
+      }
+      if(!this.state.pictureUrl || this.state.pictureUrl.length === 0){
+        message.warning('请选择新闻大图');
+        return ;
+      }
       if (this.state.flag) {
         $.ajax({
           method: "post",
@@ -454,16 +469,18 @@ const FirmList = Form.create()(
               ? 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 ? flag : undefined
+            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();
             }
@@ -487,16 +504,17 @@ const FirmList = Form.create()(
             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 ? flag : undefined,
+            releaseStatus: flag,
             status: 0,
             releaseTimes: this.state.time
           },
           success: function(data) {
-            let theArr = [];
             if (data.error && data.error.length) {
               message.warning(data.error[0].message);
             } else {
+              message.success('操作成功');
               this.loadData();
               this.handleCancelEdit();
             }
@@ -593,14 +611,20 @@ const FirmList = Form.create()(
         publisher: undefined,
         type: undefined,
         sort: undefined,
+        locations: [],
         editorcontext: "",
-        time: undefined
+        time: undefined,
+        indeterminate: false,
       });
     },
     //搜索部分的清零
     reset() {
-      this.state.titleSearch = undefined;
-      this.loadData();
+      this.setState({
+        locationSearch: '',
+        titleSearch: undefined,
+      },()=>{
+        this.loadData();
+      })
     },
 
     render() {
@@ -636,6 +660,22 @@ const FirmList = Form.create()(
                   this.setState({ titleSearch: e.target.value });
                 }}
               />
+              <Select
+                  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.title}</Select.Option>
+                  ))
+                }
+              </Select>
               <Button
                 type="primary"
                 onClick={e => {
@@ -681,11 +721,6 @@ const FirmList = Form.create()(
               visible={this.state.editvisible}
               footer=""
             >
-              <Form
-                layout="horizontal"
-                onSubmit={this.edithandleSubmit}
-                id="demand-form"
-              >
                 <SpinContainer spinning={this.state.loading}>
                   <div className="clearfix">
                     <FormItem
@@ -783,6 +818,26 @@ const FirmList = Form.create()(
                         style={{ width: "240px" }}
                       />
                     </FormItem>
+                    <FormItem
+                        className="half-item"
+                        labelCol={{ span: 8 }}
+                        wrapperCol={{ span: 12 }}
+                        label="公司"
+                    >
+                      <Checkbox.Group value={this.state.locations} onChange={e => {
+                        this.setState({
+                          locations: e.indexOf(undefined) === -1 ? e : getCompanyValueArray(),
+                          indeterminate: e.indexOf(undefined) !== -1
+                        });
+                      }}>
+                        <Checkbox indeterminate={this.state.indeterminate}>全选</Checkbox>
+                        {
+                          companyList.map((v)=>(
+                              <Checkbox key={v.value} value={v.value}>{v.title}</Checkbox>
+                          ))
+                        }
+                      </Checkbox.Group>
+                    </FormItem>
                   </div>
                   <div className="clearfix">
                     <FormItem
@@ -846,7 +901,6 @@ const FirmList = Form.create()(
                     </Button>
                   </div>
                 </SpinContainer>
-              </Form>
             </Modal>
             <Modal
               visible={this.state.imgeditvisible}

+ 26 - 0
js/component/common/configure.jsx

@@ -0,0 +1,26 @@
+const companyList = [
+    {value:0,title:'广西'}  ,
+    {value:1,title:'广州'}  ,
+    {value:2,title:'石家庄'}  ,
+];
+
+function getCompanyName(value){
+    let arr = companyList.filter(v=>v.value === value);
+    let title = '';
+    if(arr.length > 0){title = arr[0].title}
+    return title;
+}
+
+function getCompanyValueArray(){
+    let arr = [];
+    companyList.map(v=>{
+        arr.push(v.value)
+    })
+    return arr;
+}
+
+module.exports = {
+    companyList,
+    getCompanyName,
+    getCompanyValueArray
+}

+ 2 - 2
js/component/richTextEditors.jsx

@@ -106,7 +106,7 @@ const Editors = React.createClass({
     componentWillReceiveProps(nextProps) {
             this.state.theBool = true;
             // if(nextProps.textContent){
-                this.state.value = nextProps.textContent;
+                this.state.value = nextProps.textContent || '';
             // }
     },
     render() {
@@ -148,4 +148,4 @@ const Editors = React.createClass({
     },
 });
 
-export default Editors;
+export default Editors;

Datei-Diff unterdrückt, da er zu groß ist
+ 7427 - 0
yarn.lock