Quellcode durchsuchen

组织机构,增加组织编号增加修改

dev01 vor 2 Jahren
Ursprung
Commit
4325ffc492

+ 175 - 0
js/component/common/cascaders/index.jsx

@@ -0,0 +1,175 @@
+import React, { Component } from "react";
+import { Button, message, Modal, Spin, Table, Checkbox, Collapse, } from "antd";
+import $ from "jquery/src/ajax";
+
+const params = {
+  "authTree": [
+    {
+      "authName": "商场数据分析",
+      "authId": 1,
+      "children": [{
+        "authName": "数据概览",
+        "authId": 3,
+      },
+      {
+        "authName": "数据概览2",
+        "authId": 4,
+      }]
+    },
+    {
+      "authName": "商场数据分析2",
+      "authId": 2,
+      "children": [{
+        "authName": "数据概览3",
+        "authId": 5,
+      }]
+    }
+  ],
+  "checkedList": [6, 7, 11]
+}
+
+class Cascaders extends Component {
+  constructor(props) {
+    super(props);
+    this.state = {
+      visible: false,
+      authTree: [],
+      checkedList: [],
+    };
+    this.itemHandle = this.itemHandle.bind(this);
+  }
+
+
+  componentDidMount() {
+    // 后端返回的数据,转成前端要用的数据保存页面使用
+    const authTree = params.authTree;
+    const checkedList = params.checkedList;
+    this.setState({
+      authTree,
+      checkedList,
+    }, () => {
+      this.authTreeFun();
+    });
+  }
+
+  // 转成前端要用的数据
+  authTreeFun() {
+    const checkedList = this.state.checkedList;
+    checkedList.forEach((item) => {
+      this.itemHandle(item);
+    });
+  }
+
+  // 代码三级联动核心就在这里
+  itemHandle(authId, checked = true) {
+    const authTree = [...this.state.authTree];
+
+    authTree.forEach((item1) => {
+      if (item1.authId === authId) {
+        item1.checked = checked;
+        if (item1.children) {
+          item1.children.forEach((item2) => {
+            item2.checked = checked;
+            // if (item2.children) {
+            //   item2.children.forEach((item3) => {
+            //     item3.checked = checked;
+            //   });
+            // }
+          });
+        }
+      } else {
+        // 反向思路: 保存子选项框的个数, 子选项选中就-1, 等于0说明都选中了, 父选项就勾上
+        let temp1 = item1.children.length;
+        item1.children.forEach((item2) => {
+          if (item2.authId === authId) {
+            item2.checked = checked;
+            // if (item2.children) {
+            //   item2.children.forEach((item3) => {
+            //     item3.checked = checked;
+            //   });
+            // }
+          } else {
+            // let temp2 = item2.children.length;
+            // item2.children.forEach((item3) => {
+            //   if (item3.authId === authId) {
+            //     item3.checked = checked;
+            //   }
+            //   item3.checked ? temp2 -= 1 : temp2;
+            // });
+            // temp2 === 0 ? item2.checked = true : item2.checked = false;
+          }
+          //  选中-1, 未选中不动
+          item2.checked ? temp1 -= 1 : temp1;
+        });
+        //  长度是0, 父选项框就勾选
+        temp1 === 0 ? item1.checked = true : item1.checked = false;
+      }
+    });
+
+    this.setState({
+      authTree,
+    });
+  }
+
+
+  render() {
+    const { Panel } = Collapse;
+    const authTreeMap = this.state.authTree.map((item1) => (
+      // Panel是手风琴
+      <Panel
+        key={item1.authId}
+        header={(
+          <span onClick={(e) => { e.stopPropagation(); }}>
+            {/* 一级复选框(向下操控二级三级) */}
+            <Checkbox
+              name={item1.authId.toString()}
+              checked={item1.checked}
+              onClick={(e) => {
+                this.itemHandle(parseInt(e.target.name), e.target.checked);
+              }}
+            >
+              {item1.authName}
+            </Checkbox>
+          </span>
+        )}
+      >
+        {/* 二级复选框(向下操控三级,向上联动一级) */}
+        {item1.children.map((item2) => (
+          <div key={item2.authId}>
+            <Checkbox
+              name={item2.authId.toString()}
+              checked={item2.checked}
+              onClick={(e) => {
+                this.itemHandle(parseInt(e.target.name), e.target.checked);
+              }}
+            >
+              {item2.authName}
+            </Checkbox>
+            {/* <span>|</span>
+            {item2.children.map((item3) => (
+              <Checkbox
+                key={item3.authId}
+                name={item3.authId.toString()}
+                checked={item3.checked}
+                onClick={(e) => {
+                  this.itemHandle(parseInt(e.target.name), e.target.checked);
+                }}
+              >
+                {item3.authName}
+              </Checkbox>
+            ))} */}
+          </div>
+        ))}
+      </Panel>
+    ));
+    return (
+      <div>
+        <Collapse expandIconPosition="right">
+          {authTreeMap}
+        </Collapse>
+      </div>
+    );
+  }
+}
+
+export default Cascaders;

+ 2 - 0
js/component/manageCenter/channelList/channelunit/index.jsx

@@ -24,6 +24,7 @@ import ChangeLog from "./changelog"; //更名日志
 import ChannelDetail from "./channeldetail"; //渠道详情
 import FollowDetail from "../../../../component/manageCenter/customer/NEW/intentionCustomer/followDetail";//新增渠道跟进
 import ShowModalDiv from "@/showModal.jsx";
+import Cascaders from "../../../common/cascaders"
 
 const { TabPane } = Tabs;
 const FormItem = Form.Item;
@@ -917,6 +918,7 @@ class ChannelUnit extends Component {
             />
           </Spin>
         </div>
+        {/* <Cascaders /> */}
         {this.state.informationTransferVisible && (
           <Modal
             visible={this.state.informationTransferVisible}

+ 1 - 1
js/component/manageCenter/order/orderNew/changeComponent/changeDetailYxy.js

@@ -307,7 +307,7 @@ class ChangeDetail extends Component {
       data: {
         orderNo: this.props.data.orderNo,
         type: this.props.data.type,
-        id: this.props.data.id,
+        id: this.props.id,
         attachmentUrl: this.state.refundUrl,
       },
       success: data => {

+ 1 - 1
js/component/manageCenter/order/orderNew/contractCwjl.js

@@ -1417,7 +1417,7 @@ const contractChange = Form.create()(
                             : undefined
                         }
                         data={this.state.contractData}
-                        loadData={this.ChangeDetail}
+                        // loadData={this.ChangeDetail}
                         txt={this.state.processStateText}
                         pictureUrl={this.state.voucherUrl}
                          attachment = {this.state.attachment}

+ 53 - 8
js/component/manageCenter/set/organization/organization.jsx

@@ -31,7 +31,7 @@ const Organization = Form.create()(React.createClass({
                 name: this.state.name, //组织名称
                 superId: this.state.superId,//上级组织
                 type: this.state.type,//组织类型
-                depNo: this.state.depNo,//组织编号
+                depNo: this.state.depNo1,//组织编号
             },
             success: function (data) {
                 let theArr = [];
@@ -73,6 +73,7 @@ const Organization = Form.create()(React.createClass({
     },
     getInitialState() {
         return {
+            editvisible: false,
             workingHoursType: 0,
             searchMore: true,
             selectedRowKeys: [],
@@ -209,6 +210,10 @@ const Organization = Form.create()(React.createClass({
     //编辑部门,保存
     edithandleSubmit(e) {
         e.preventDefault();
+        if (!this.state.depNo) {
+            message.warning('请填写组织编号');
+            return
+        }
         //上级组织字典
         let nameText = this.state.SuperArr
         let superText = this.state.editSuperId;
@@ -257,6 +262,7 @@ const Organization = Form.create()(React.createClass({
                                         abbreviation: _this.state.abbreviation,
                                         workingHoursType: _this.state.workingHoursType,
                                         hideSign: _this.state.hideSign,//显示标识
+                                        depNo: _this.state.depNo,//组织编号
                                     }
                                 }).done(
                                     function (data) {
@@ -299,6 +305,7 @@ const Organization = Form.create()(React.createClass({
                                 abbreviation: _this.state.abbreviation,
                                 workingHoursType: _this.state.workingHoursType,
                                 hideSign: _this.state.hideSign,//显示标识
+                                depNo: _this.state.depNo,//组织编号
                             }
                         }).done(
                             function (data) {
@@ -346,6 +353,7 @@ const Organization = Form.create()(React.createClass({
                                 abbreviation: _this.state.abbreviation,
                                 workingHoursType: _this.state.workingHoursType,
                                 hideSign: _this.state.hideSign,//显示标识
+                                depNo: _this.state.depNo,//组织编号
                             }
                         }).done(
                             function (data) {
@@ -389,6 +397,7 @@ const Organization = Form.create()(React.createClass({
                         province: _this.state.province,
                         workingHoursType: _this.state.workingHoursType,
                         hideSign: _this.state.hideSign,//显示标识
+                        depNo: _this.state.depNo,//组织编号
                     }
                 }).done(
                     function (data) {
@@ -436,7 +445,7 @@ const Organization = Form.create()(React.createClass({
                         editStatus: thisdata.status, //组织状态
                         province: thisdata.province,//省份
                         editSuperId: thisdata.superId, //上级组织
-                        editDepNo: thisdata.depNo, //组织编号
+                        depNo: thisdata.depNo, //组织编号
                         editCreateId: thisdata.createId, //创建人
                         editTime: thisdata.createTime, //创建时间
                         editRemarks: thisdata.remarks, //组织职能说明
@@ -455,7 +464,7 @@ const Organization = Form.create()(React.createClass({
                         editStatus: thisdata.status, //组织状态
                         province: thisdata.province, //省份
                         editSuperId: thisdata.superId, //上级组织
-                        editDepNo: thisdata.depNo, //组织编号
+                        depNo: thisdata.depNo, //组织编号
                         editCreateId: thisdata.createId, //创建人
                         editTime: thisdata.createTime, //创建时间
                         editRemarks: thisdata.remarks, //组织职能说明
@@ -522,6 +531,10 @@ const Organization = Form.create()(React.createClass({
             message.warning('请选择上级组织');
             return false;
         }
+        if (!this.state.depNo) {
+            message.warning('请填写组织编号');
+            return false;
+        }
         this.props.form.validateFields((err, values) => {
             if (!err) {
                 this.setState({
@@ -540,6 +553,7 @@ const Organization = Form.create()(React.createClass({
                         remarks: this.state.remarksOrganization,//组织职能说明
                         workingHoursType: this.state.workingHoursType,//作息时间
                         hideSign: this.state.hideSign,//显示标识
+                        depNo: this.state.depNo,//组织编号
                     }
                 }).done(function (data) {
                     this.setState({
@@ -642,6 +656,7 @@ const Organization = Form.create()(React.createClass({
         })
     },
     addClick() {
+        this.state.DepN = '';//组织编号
         this.state.theTypes = '';
         this.state.nameOrganization = '';//组织名称清零
         this.state.managerIdOrganization = '';//负责人ID清零
@@ -680,7 +695,7 @@ const Organization = Form.create()(React.createClass({
         this.state.superId = undefined;//上级组织清零
         this.state.name = '';//组织名称清零
         this.state.type = undefined;//组织类型清零
-        this.state.depNo = '';//组织编号清零
+        this.state.depNo1 = '';//组织编号清零
         this.loadData();
     },
     searchSwitch() {
@@ -760,8 +775,8 @@ const Organization = Form.create()(React.createClass({
                                 <span style={{ marginRight: '20px' }}>更多搜索    <Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
                                 <div style={this.state.searchMore ? { display: 'none' } : { display: 'inline-block' }}>
                                     <Input placeholder="组织编号" style={{ width: '150px', marginRight: '10px' }}
-                                        value={this.state.depNo}
-                                        onChange={(e) => { this.setState({ depNo: e.target.value }); }} />
+                                        value={this.state.depNo1}
+                                        onChange={(e) => { this.setState({ depNo1: e.target.value }); }} />
                                     <Select placeholder="组织类型"
                                         style={{ width: '150px', marginRight: '50px' }}
                                         value={this.state.type}
@@ -774,7 +789,12 @@ const Organization = Form.create()(React.createClass({
                             </div>
                         </TabPane>
                         <TabPane tab="新增组织" key="2"   >
-                            <Button type="primary" className="addButton" onClick={this.addClick} style={{ marginBottom: '10px', float: 'left' }}>新增组织<Icon type="plus" /></Button>
+                            <Button
+                                type="primary"
+                                className="addButton"
+                                onClick={this.addClick}
+                                style={{ marginBottom: '10px', float: 'left' }}
+                            >新增组织<Icon type="plus" /></Button>
                         </TabPane>
                         <TabPane tab="更改表格显示数据" key="3">
                             <div style={{ marginLeft: 10 }}>
@@ -903,6 +923,23 @@ const Organization = Form.create()(React.createClass({
                                         <FormItem
                                             labelCol={{ span: 7 }}
                                             wrapperCol={{ span: 12 }}
+                                            label="组织编号"
+                                        >
+                                            <Input
+                                                placeholder='组织编号'
+                                                value={this.state.depNo}
+                                                onChange={(e) => {
+                                                    this.setState({
+                                                        depNo: e.target.value
+                                                    })
+                                                }}
+                                            />
+                                        </FormItem>
+                                    </div>
+                                    <div className="clearfix">
+                                        <FormItem
+                                            labelCol={{ span: 7 }}
+                                            wrapperCol={{ span: 12 }}
                                             label="组织职能说明" >
                                             <Input type="textarea" rows={4} placeholder="组织职能说明" value={this.state.remarksOrganization}
                                                 onChange={(e) => { this.setState({ remarksOrganization: e.target.value }) }} style={{ width: '95%' }} />
@@ -1100,7 +1137,15 @@ const Organization = Form.create()(React.createClass({
                                             wrapperCol={{ span: 12 }}
                                             label="组织编号"
                                         >
-                                            <span>{this.state.editDepNo}</span>
+                                            <Input
+                                                placeholder='组织编号'
+                                                value={this.state.depNo}
+                                                onChange={(e) => {
+                                                    this.setState({
+                                                        depNo: e.target.value
+                                                    })
+                                                }}
+                                            />
                                         </FormItem>
                                     </div>
                                     <div className="clearfix" >