Browse Source

订单变更最近记录

mentoswzq 5 years ago
parent
commit
04ddb522c7
1 changed files with 374 additions and 252 deletions
  1. 374 252
      js/component/manageCenter/order/orderNew/addService.jsx

+ 374 - 252
js/component/manageCenter/order/orderNew/addService.jsx

@@ -802,7 +802,7 @@ const NewService = Form.create()(
                     dataArr.forEach(item => {
                       if (item.commodityName == record.sortName) {
                         record.cname = item.cname;
-                        record.tid = item.id;
+                        record.ctid = item.id;
                         record.isSave = true;
                         record.sort = item.cSort;
                         cuiJieDian.forEach(item => {
@@ -1095,9 +1095,9 @@ const NewService = Form.create()(
                     cancelText="不删除"
                   >
                     <Button
-                    disabled={this.state.listCuiFlag}
+                      disabled={this.state.listCuiFlag}
                       style={{
-                        marginRight: "10px",
+                        marginRight: "10px"
                       }}
                     >
                       删除
@@ -1409,183 +1409,6 @@ const NewService = Form.create()(
         }.bind(this)
       );
     },
-    // //查看催款节点
-    // loaduserss(record) {
-    //   this.state.orderList = [];
-    //   this.setState({
-    //     orderNoss: record ? record.orderNo : this.props.datauser.orderNo
-    //   });
-
-    //   $.ajax({
-    //     method: "get",
-    //     dataType: "json",
-    //     crossDomain: false,
-    //     url: globalConfig.context + "/api/admin/newOrderDun/selectListNewOrderDun",
-    //     data: {
-    //       orderNo: record ? record.orderNo : this.props.datauser.orderNo
-    //     },
-    //     success: function(data) {
-    //       let theArr = [];
-    //       let thisData = [];
-    //       if (!thisData) {
-    //         if (data.error && data.error.length) {
-    //           message.warning(data.error[0].message);
-    //         }
-    //         thisData = {};
-    //       } else {
-    //         for (let i = 0; i < data.data.length; i++) {
-    //           thisData = data.data[i];
-    //           theArr.push({
-    //             key: i,
-    //             dunSubject: thisData.dunSubject
-    //               ? thisData.dunSubject.toString()
-    //               : "", //催款科目
-    //             id: thisData.id, //节点Id
-    //             money: thisData.money, //催款金额
-    //             orderNo: record ? record.orderNo : this.props.datauser.orderNo,
-    //             commodityName: thisData.commodityName,
-    //             projectType: thisData.projectType,
-    //             dunTypeName: thisData.dunTypeName,
-    //             status: thisData.status,
-    //             waitDay: thisData.waitDay,
-    //             effectiveCount: thisData.effectiveCount,
-    //             startDate: thisData.startDate
-    //           });
-    //         }
-    //         this.setState({
-    //           contactList: theArr
-    //         });
-    //       }
-    //     }.bind(this)
-    //   }).always(
-    //     function() {
-    //       this.setState({
-    //         loading: false
-    //       });
-    //     }.bind(this)
-    //   );
-    // },
-    // //催款节点保存
-    // contactSave(record) {
-    //   if(!this.state.yearFlag) {
-    //     if(!record.effectiveCount) {
-    //       message.warning("请选择服务年限")
-    //       return
-    //     }
-    //   }else {
-    //     record.effectiveCount = ""
-    //   }
-    //   if(record.money == "" ) {
-    //     message.warning("请填写金额")
-    //     return
-    //   }
-    //   if(!record.dunType) {
-    //     message.warning("请选择对应科目")
-    //     return
-    //   }
-
-    //   // if (this.state.contactList) {
-    //   //   let cuiData = this.state.contactList;
-    //   //   for (var a = 0; a < cuiData.length; a++) {
-    //   //     if (cuiData[a].money == "") {
-    //   //       message.warning("催款金额不能为空");
-    //   //       this.refs.signFirstPayment.focus();
-    //   //       return false;
-    //   //     } else if (!cuiData[a].dunSubject) {
-    //   //       message.warning("催款科目不能为空");
-    //   //       this.refs.signFirstPayment.focus();
-    //   //       return false;
-    //   //     }
-    //   //     if (moneyVerify(cuiData[a].money)) {
-    //   //       return;
-    //   //     }
-    //   //   }
-    //   // }
-    //   this.setState({
-    //     loading: true
-    //   });
-    //   $.ajax({
-    //     url: globalConfig.context + "/api/admin/newOrderDun/createDun",
-    //     method: "post",
-    //     data: {
-    //       orderNo: record.orderNo,
-    //       tid: record.tid,
-    //       projectType: record.sort,
-    //       dunType: record.dunType,
-    //       money: record.money,
-    //       waitDay: record.waitDay,
-    //       effectiveCount: record.effectiveCount
-    //     }
-    //   }).done(
-    //     function(data) {
-    //       this.setState({
-    //         loading: false
-    //       });
-    //       if (!data.error.length) {
-    //         message.success("保存成功!");
-    //         this.setState({
-    //           cuiFlag: false
-    //         });
-    //         this.jiedian();
-    //       } else {
-    //         message.warning(data.error[0].message);
-    //       }
-    //     }.bind(this)
-    //   );
-    // },
-    // //点击新增催款节点
-    // addcontact() {
-    //   this.state.contactList.push({
-    //     key: this.state.contactList.length,
-    //     money: "",
-    //     dunSubject: undefined,
-    //     orderNo: this.state.orderNoss,
-    //     dunTarget: this.state.kehuId
-    //   });
-    //   this.setState({
-    //     contactList: this.state.contactList,
-    //     cuiFlag: true
-    //   });
-    // },
-
-    // //删除收款节点
-    // confirmDelet(index) {
-    //   if (index.id) {
-    //     this.state.contactList.splice(index.key, 1);
-    //     this.setState({
-    //       contactList: this.state.contactList,
-    //       cuiFlag: false
-    //     });
-    //     $.ajax({
-    //       url: globalConfig.context + "/api/admin/newOrderDun/deleteDun",
-    //       method: "post",
-    //       data: {
-    //         id: index.id,
-    //       }
-    //     }).done(
-    //       function(data) {
-    //         this.setState({
-    //           loading: false
-    //         });
-    //         if (!data.error.length) {
-    //           message.success("删除成功!");
-    //           this.setState({
-    //             cuiFlag: false
-    //           });
-    //           this.jiedian();
-    //         } else {
-    //           message.warning(data.error[0].message);
-    //         }
-    //       }.bind(this)
-    //     );
-    //   } else {
-    //     this.state.contactList.splice(index.key, 1);
-    //     this.setState({
-    //       contactList: this.state.contactList,
-    //       cuiFlag: false
-    //     });
-    //   }
-    // },
     //节点列表
     jiedian(orderNos) {
       $.ajax({
@@ -1929,7 +1752,8 @@ const NewService = Form.create()(
           mark: false,
           cuiFlag: false,
           addFlag: false,
-          boFlag: false
+          boFlag: false,
+          isJilu: false
         },
         () => {
           this.setState({
@@ -2054,6 +1878,10 @@ const NewService = Form.create()(
       if (key === "1") {
         this.jiedian(this.props.datauser.orderNo);
         this.jiedianNew(this.props.datauser.orderNo);
+        // this.loaduser();
+      }
+      if (key === "3") {
+        this.getChangeData();
       }
       if (key === "2") {
         let url = window.location.href.substring(7);
@@ -2141,7 +1969,9 @@ const NewService = Form.create()(
                   listFlag: false,
                   hetongFlag: false,
                   listCuiFlag: false,
-                  tuiKuanFlag: false
+                  tuiKuanFlag: false,
+                  // 置空
+                  changeId: undefined
                 });
               }
             } else {
@@ -2153,18 +1983,22 @@ const NewService = Form.create()(
         });
       }
     },
-    cuiList() {
+    cuiList(id) {
       $.ajax({
         method: "get",
         dataType: "json",
         crossDomain: false,
         url: globalConfig.context + "/api/admin/orderChange/selectChangeDun",
         data: {
-          id: this.state.changeId
+          id: id || this.state.changeId
         },
         success: function(data) {
           if (data.data && data.data.length) {
-            console.log(data);
+            if(id) {
+              this.setState({
+                listCuiFlag: true
+              })
+            }
             this.setState({
               cuiDataSource: data.data
             });
@@ -2172,19 +2006,22 @@ const NewService = Form.create()(
         }.bind(this)
       });
     },
-    proList() {
+    proList(id) {
       $.ajax({
         method: "get",
         dataType: "json",
         crossDomain: false,
         url: globalConfig.context + "/api/admin/orderChange/selectChangeTask",
         data: {
-          id: this.state.changeId
+          id: id || this.state.changeId
         },
         success: function(data) {
-          // console.log(data.data);
           if (data.data && data.data.length) {
-            console.log(data);
+            if(id) {
+              this.setState({
+                listFlag: true
+              })
+            }
             this.setState({
               proDataSource: data.data
             });
@@ -2659,46 +2496,79 @@ const NewService = Form.create()(
       }
       this.setState({
         loading: true
-      })
-      $.ajax({
-        method: "post",
-        dataType: "json",
-        crossDomain: false,
-        url: globalConfig.context + "/api/admin/orderChange/addOrderChange",
-        data: {
-          orderNo: this.state.orderNo, //订单编号
-          processState: 0,
-          status: 0,
-          startRemarks: this.state.startRemarks,
-          remarks: this.state.remarksC,
-          voucherUrl: theorgCodeUrl.length ? theorgCodeUrl : "",
-          totalAmount: this.state.totalAmount,
-          settlementAmount: this.state.settlementAmount,
-          changeAmount: this.state.changeAmount,
-          applicant: this.state.salesmanName,
-          depName: this.state.depName,
-          type: this.state.typeChange
-        }
-      }).done(
-        function(data) {
-          this.setState({
-            loading: false
-          });
-          if (!data.error.length) {
-            message.success("发起变更草稿");
+      });
+      if (this.state.typeChange == 0) {
+        $.ajax({
+          method: "post",
+          dataType: "json",
+          crossDomain: false,
+          url: globalConfig.context + "/api/admin/orderChange/addOrderChange",
+          data: {
+            orderNo: this.state.orderNo, //订单编号
+            processState: 1,
+            status: 1,
+            startRemarks: this.state.startRemarks,
+            remarks: this.state.remarksC,
+            voucherUrl: theorgCodeUrl.length ? theorgCodeUrl : "",
+            totalAmount: this.state.totalAmount,
+            settlementAmount: this.state.settlementAmount,
+            changeAmount: this.state.changeAmount,
+            applicant: this.state.salesmanName,
+            depName: this.state.depName,
+            type: this.state.typeChange
+          }
+        }).done(
+          function(data) {
             this.setState({
-              isCaoGao: true,
-              loading: false,
+              loading: false
             });
-            this.noCancel();
-            this.handleCancelclose();
-            // this.handleCancelclose();
-            this.callback();
-          } else {
-            message.warning(data.error[0].message);
+            if (!data.error.length) {
+              message.success("发起变更成功");
+              this.handleCancelclose();
+            } else {
+              message.warning(data.error[0].message);
+            }
+          }.bind(this)
+        );
+      } else {
+        $.ajax({
+          method: "post",
+          dataType: "json",
+          crossDomain: false,
+          url: globalConfig.context + "/api/admin/orderChange/addOrderChange",
+          data: {
+            orderNo: this.state.orderNo, //订单编号
+            processState: 0,
+            status: 0,
+            startRemarks: this.state.startRemarks,
+            remarks: this.state.remarksC,
+            voucherUrl: theorgCodeUrl.length ? theorgCodeUrl : "",
+            totalAmount: this.state.totalAmount,
+            settlementAmount: this.state.settlementAmount,
+            changeAmount: this.state.changeAmount,
+            applicant: this.state.salesmanName,
+            depName: this.state.depName,
+            type: this.state.typeChange
           }
-        }.bind(this)
-      );
+        }).done(
+          function(data) {
+            this.setState({
+              loading: false
+            });
+            if (!data.error.length) {
+              message.success("发起变更草稿");
+              this.setState({
+                isCaoGao: true,
+                loading: false,
+              },() => {
+                this.callback("2");
+              });
+            } else {
+              message.warning(data.error[0].message);
+            }
+          }.bind(this)
+        );
+      }
     },
 
     reset() {
@@ -2727,6 +2597,7 @@ const NewService = Form.create()(
         this.jiedian(nextProps.datauser.orderNo);
         this.jiedianNew(nextProps.datauser.orderNo);
         this.loadData(nextProps.datauser);
+        this.getChangeData(nextProps.datauser);
       } else {
         this.setState({
           orderType: undefined,
@@ -2739,6 +2610,55 @@ const NewService = Form.create()(
         });
       }
     },
+    //查看变更记录
+    getChangeData(record) {
+      this.setState({
+        loading: true
+      });
+      $.ajax({
+        method: "get",
+        dataType: "json",
+        crossDomain: false,
+        url: globalConfig.context + "/api/admin/orderChange/orderChangeDetails",
+        data: {
+          orderNo: record ? record.orderNo : this.props.datauser.orderNo
+        },
+        success: function(data) {
+          this.setState({
+            loading: false
+          });
+          let url = window.location.href.substring(7);
+          // console.log(data.data);
+          if (data.data && data.data.length) {
+            let thisdata = data.data[data.data.length - 1];
+            let obj = {
+              id: thisdata.id,
+              typeChange: thisdata.type,
+              totalAmount: thisdata.totalAmount,
+              settlementAmount: thisdata.settlementAmount,
+              changeAmount: thisdata.changeAmount,
+              remarksC: thisdata.remarks,
+              startRemarks: thisdata.zxsRemarks,
+              voucherUrl: thisdata.voucherUrl
+                ? splitUrl(
+                    thisdata.voucherUrl,
+                    ",",
+                    globalConfig.avatarHost + "/upload",
+                    url
+                  )
+                : []
+            };
+            this.proList(thisdata.id);
+            this.cuiList(thisdata.id);
+            this.setState({
+              //判断是否有合同变更记录
+              isJilu: true,
+              detailChange: obj
+            });
+          }
+        }.bind(this)
+      });
+    },
     showConfirm(fn, record) {
       confirm({
         title: "确定删除此项目吗?",
@@ -2793,6 +2713,10 @@ const NewService = Form.create()(
       this.setState({
         loading: true
       });
+      let type = 0;
+      if (this.state.typeChange == 4 || this.state.typeChange == 5) {
+        type = 1;
+      }
       $.ajax({
         method: "post",
         dataType: "json",
@@ -2806,7 +2730,8 @@ const NewService = Form.create()(
           commodityPrice: this.state.commodityPrice, //签单总价
           taskComment: this.state.taskComment, //服务说明
           main: this.state.main, //是否为主要项目
-          cid: this.state.changeId //变更ID
+          cid: this.state.changeId, //变更ID
+          type
         },
         success: function(data) {
           let theArr = [];
@@ -2957,7 +2882,7 @@ const NewService = Form.create()(
           method: "post",
           data: {
             orderNo: record.orderNo,
-            tid: record.tid,
+            ctid: record.ctid,
             projectType: record.sort,
             dunType: record.dunType,
             appropriationRatio: record.appropriationRatio,
@@ -2989,7 +2914,7 @@ const NewService = Form.create()(
           method: "post",
           data: {
             orderNo: record.orderNo,
-            tid: record.tid,
+            ctid: record.ctid,
             projectType: record.sort,
             dunType: record.dunType,
             money: record.money,
@@ -3052,7 +2977,7 @@ const NewService = Form.create()(
       }
       this.setState({
         loading: true
-      })
+      });
       $.ajax({
         url: globalConfig.context + "/api/admin/orderChange/updateOrderChange",
         method: "post",
@@ -4129,7 +4054,6 @@ const NewService = Form.create()(
                                       startRemarks: "",
                                       remarksC: "",
                                       voucherUrl: [],
-                                      totalAmount: "0",
                                       changeAmount: "0",
                                       applicant: undefined,
                                       depNameChange: undefined,
@@ -4399,13 +4323,17 @@ const NewService = Form.create()(
                                 // onClick={this.changeApply}
                                 onClick={e => {
                                   if (this.state.isCaoGao) {
-                                    this.submitChange()
+                                    this.submitChange();
                                   } else {
                                     this.changeApply();
                                   }
                                 }}
                               >
-                                {this.state.isCaoGao ? "发起变更申请" : "确定"}
+                                {this.state.isCaoGao
+                                  ? "发起变更申请"
+                                  : this.state.typeChange == 0
+                                  ? "发起变更申请"
+                                  : "下一步"}
                               </Button>
                             </div>
                             {/* ) : (
@@ -4414,6 +4342,219 @@ const NewService = Form.create()(
                           </div>
                         }
                       </TabPane>
+                      {this.state.isJilu ? (
+                        <TabPane tab={"最近变更记录"} key="3">
+                          <div>
+                            <div className="clearfix">
+                              <FormItem
+                                className="half-item"
+                                {...formItemLayout}
+                                label="客户名称"
+                              >
+                                <span>{this.state.userName}</span>
+                              </FormItem>
+                            </div>
+                            <div className="clearfix">
+                              <FormItem
+                                className="half-item"
+                                {...formItemLayout}
+                                label="合同编号"
+                              >
+                                <span>{this.state.contractNo}</span>
+                              </FormItem>
+                            </div>
+                            <div className="clearfix">
+                              <FormItem
+                                className="half-item"
+                                {...formItemLayout}
+                                label="申请变更部门"
+                              >
+                                <span>{this.state.depName}</span>
+                              </FormItem>
+                              <FormItem
+                                className="half-item"
+                                {...formItemLayout}
+                                label="申请人"
+                              >
+                                <span>{this.state.salesmanName}</span>
+                              </FormItem>
+                            </div>
+                            <div className="clearfix">
+                              <FormItem
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="变更类型"
+                              >
+                                <span>
+                                  {getChangeType(
+                                    this.state.detailChange.typeChange
+                                  )}
+                                </span>
+                              </FormItem>
+                            </div>
+                            <div className="clearfix">
+                              <FormItem
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="合同额(万元)"
+                              >
+                                <span>
+                                  {this.state.detailChange.totalAmount}
+                                </span>
+                              </FormItem>
+                              <FormItem
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="已收款(万元)"
+                              >
+                                <span>
+                                  {this.state.detailChange.settlementAmount}
+                                </span>
+                              </FormItem>
+                              <FormItem
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="申请退款(万元)"
+                              >
+                                <span>
+                                  {this.state.detailChange.changeAmount}
+                                </span>
+                              </FormItem>
+                            </div>
+                            {/* 动态展示项目以及催款节点 */}
+                            <div>
+                              <div>
+                                <span
+                                  style={{
+                                    marginLeft: "50px",
+                                    fontSize: "20px"
+                                  }}
+                                >
+                                  项目业务
+                                </span>
+                              </div>
+                              <div
+                                className="patent-table"
+                                style={{ marginBottom: 10 }}
+                              >
+                                <Spin spinning={this.state.loading}>
+                                  <Table
+                                    columns={this.state.proColumns}
+                                    dataSource={this.state.proDataSource}
+                                    pagination={this.state.pagination}
+                                    // onRowClick={this.tableRowClick}
+                                    bordered
+                                    size="small"
+                                  />
+                                </Spin>
+                              </div>
+                              <div>
+                                <span
+                                  style={{
+                                    marginLeft: "50px",
+                                    fontSize: "20px"
+                                  }}
+                                >
+                                  催款节点
+                                </span>
+                                {/* <span
+                                style={{
+                                  display: "inline-block",
+                                  marginLeft: 10,
+                                  color: "red"
+                                }}
+                              >
+                                金额总计(万元): {this.state.totalCui}
+                              </span> */}
+                              </div>
+                              <div className="clearfix">
+                                <Spin spinning={this.state.loading}>
+                                  <Form layout="horizontal">
+                                    <Table
+                                      pagination={false}
+                                      columns={this.state.changeCuiList}
+                                      dataSource={this.state.cuiDataSource}
+                                      scroll={{ x: "max-content", y: 0 }}
+                                      bordered
+                                      size="small"
+                                    />
+                                    <Col
+                                      span={24}
+                                      offset={9}
+                                      style={{ marginTop: "15px" }}
+                                    ></Col>
+                                  </Form>
+                                </Spin>
+                              </div>
+                            </div>
+                            <div className="clearfix">
+                              <FormItem
+                                style={{ height: "auto" }}
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="变更原因"
+                              >
+                                <span>{this.state.detailChange.remarksC}</span>
+                              </FormItem>
+                            </div>
+                            <div className="clearfix">
+                              <FormItem
+                                style={{ height: "auto" }}
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="备注"
+                              >
+                                <span>
+                                  {this.state.detailChange.startRemarks}
+                                </span>
+                              </FormItem>
+                            </div>
+
+                            {/* ---- */}
+                            <div className="clearfix">
+                              <FormItem
+                                labelCol={{ span: 4 }}
+                                wrapperCol={{ span: 18 }}
+                                label="变更凭证"
+                              >
+                                <div>
+                                  <Upload
+                                    className="demandDetailShow-upload"
+                                    listType="picture-card"
+                                    fileList={
+                                      this.state.detailChange.voucherUrl
+                                    }
+                                    onPreview={file => {
+                                      this.setState({
+                                        previewImage: file.url || file.thumbUrl,
+                                        previewVisible: true
+                                      });
+                                    }}
+                                  />
+                                  <Modal
+                                    maskClosable={false}
+                                    footer={null}
+                                    visible={this.state.previewVisible}
+                                    onCancel={() => {
+                                      this.setState({
+                                        previewVisible: false
+                                      });
+                                    }}
+                                  >
+                                    <img
+                                      alt=""
+                                      style={{ width: "100%" }}
+                                      src={this.state.previewImage || ""}
+                                    />
+                                  </Modal>
+                                </div>
+                              </FormItem>
+                            </div>
+                          </div>
+                        </TabPane>
+                      ) : (
+                        ""
+                      )}
                     </Tabs>
                   )}
                 </div>
@@ -4924,25 +5065,6 @@ const NewService = Form.create()(
               </Spin>
             </Form>
           </Modal>
-          {/* <Modal
-            visible={this.state.rizhivisible}
-            className="admin-desc-content"
-            width="800px"
-            maskClosable={false}
-            title="订单日志"
-            footer={null}
-            onCancel={this.closeOrderLog}
-          >
-            <div className="patent-table">
-              <Spin spinning={this.state.loading}>
-                <Table
-                  columns={this.state.columnsrizhi}
-                  dataSource={this.state.dataSourcerizhi}
-                  pagination={false}
-                />
-              </Spin>
-            </div>
-          </Modal> */}
           <OrderRiZi
             dataSourcerizhi={this.state.dataSourcerizhi}
             closeOrderLog={this.closeOrderLog}