Browse Source

我的会员项目驳回重新发起bug修复

dev01 1 year ago
parent
commit
1dc9aba9ed

+ 223 - 154
js/component/common/projectOperation/vip.jsx

@@ -1,6 +1,7 @@
 import React, { Component } from "react";
-import { AutoComplete, Button, Form, Input, message, Modal, Select, Spin, Tag, Radio } from "antd";
+import { AutoComplete, Button, Form, Input, message, Modal, Select, Spin, Tag, Radio, DatePicker } from "antd";
 import $ from "jquery";
+import moment from "moment";
 import ImgList from "../../common/imgList";
 import { splitUrl } from "../../tools";
 import { vipYear } from "../../dataDic";
@@ -9,6 +10,7 @@ const FormItem = Form.Item;
 const Option = Select.Option;
 const RadioGroup = Radio.Group;
 
+
 const formItemLayout = {
   labelCol: { span: 8 },
   wrapperCol: { span: 14 },
@@ -88,6 +90,7 @@ class ProjectOperationVip extends Component {
       orgCodeUrl: [],
       serviceLife: [],
       histYear: [], //已派年份
+      serviceYear: undefined, //本次派单
       isEdit: false,//是否可编辑
       contractTerm: [],//合同期
       addyear: undefined,//
@@ -106,39 +109,24 @@ class ProjectOperationVip extends Component {
   }
 
   setValue() {
-    const { dataInfor, newData } = this.props;
-    if (!!newData && newData.length > 0) {
-      let list = []
-      for (var i = 0; i < newData.length; i++) {
-        if (newData[i].cSort == 6) {
-          list.push({
-            commodityId: newData[i].commodityId,
-            commodityName: newData[i].commodityName,
-          })
-        }
-      }
+    const { dataInfor } = this.props;
+    if (!(dataInfor && Object.keys(dataInfor).length > 0)) {
+
+    } else {
       this.setState({
-        customerArr: list
-      })
+        fid: dataInfor.id,
+        commodityId: dataInfor.commodityId, //项目ID
+        commodityName: dataInfor.commodityName, //项目名称
+        commodityQuantity: dataInfor.commodityQuantity, // 数量
+        memberType: dataInfor.memberType.toString(),// 付款情况
+        taskComment: dataInfor.taskComment, // 备注
+        orgCodeUrl: dataInfor.pictureUrl ? splitUrl(dataInfor.pictureUrl, ",", globalConfig.avatarHost + "/upload") : [],// 附件
+        yearSum: dataInfor.yearSum && dataInfor.yearSum.toString() || undefined,//会员总服务年限
+        serviceLife: JSON.parse(dataInfor.serviceLife) || [],//会员服务年限
+        serviceYear: dataInfor.serviceYear || undefined,//本次派单
+        contractTerm: (!dataInfor.contractTerm || (dataInfor.contractTerm.indexOf("-") == -1)) ? [] : JSON.parse(dataInfor.contractTerm),//合同期
+      });
     }
-    // if (!(dataInfor && Object.keys(dataInfor).length > 0)) {
-
-    // } else {
-    //   this.setState({
-    //     fid: dataInfor.id,
-    //     commodityId: dataInfor.commodityId, //项目ID
-    //     commodityName: dataInfor.commodityName, //项目名称
-    //     commodityQuantity: dataInfor.commodityQuantity, // 数量
-    //     memberType: dataInfor.memberType.toString(),// 付款情况
-    //     taskComment: dataInfor.taskComment, // 备注
-    //     orgCodeUrl: dataInfor.pictureUrl ? splitUrl(dataInfor.pictureUrl, ",", globalConfig.avatarHost + "/upload") : [],// 附件
-    //     yearSum: dataInfor.yearSum,//会员总服务年限
-    //     serviceLife: JSON.parse(dataInfor.serviceLife) || [],//会员服务年限
-    //     serviceYear: dataInfor.serviceYear,//本次派单
-    //     contractTerm: JSON.parse(dataInfor.contractTerm),//合同期
-    //     taskComment: dataInfor.taskComment,//项目说明
-    //   });
-    // }
   }
   //
   getOrgCodeUrl(e) {
@@ -249,6 +237,102 @@ class ProjectOperationVip extends Component {
       }.bind(this)
     );
   }
+  // 修改会员项目
+  onChange() {
+
+    let pictureUrl = [];
+    if (this.state.orgCodeUrl.length) {
+      let picArr = [];
+      this.state.orgCodeUrl.map(function (item) {
+        if (
+          item.response &&
+          item.response.data &&
+          item.response.data.length
+        ) {
+          picArr.push(item.response.data);
+        }
+      });
+      pictureUrl = picArr.join(",");
+    }
+
+    if (this.state.commodityId === undefined || !this.state.commodityId) {
+      message.warning("服务名称不匹配!");
+      return
+    }
+    let reg = /^([0]|[1-9][0-9]*)$/;
+    if (
+      !this.state.commodityQuantity ||
+      !reg.test(this.state.commodityQuantity)
+    ) {
+      message.warning("请输入正确商品数量!");
+      return false;
+    }
+    if (this.state.memberType === undefined) {
+      message.warning("请选择付款情况!");
+      return
+    }
+    if (this.state.yearSum === undefined) {
+      message.warning("请选择会员总服务年限!");
+      return
+    }
+    if (this.state.serviceLife.length === 0) {
+      message.warning("请添加会员服务年限!");
+      return
+    }
+    if (this.state.serviceLife.length != this.state.yearSum) {
+      message.warning("会员服务年限与总年限不符合!");
+      return
+    }
+    if (this.state.serviceYear === undefined) {
+      message.warning("请选择本次派单年份!");
+      return
+    }
+    if (this.state.contractTerm.length === 0) {
+      message.warning("请添加合同期!");
+      return
+    }
+    if (this.state.memberType == "1" || this.state.memberType == "2") {
+      if (typeof pictureUrl !== "string") {
+        message.warning("请上传附件!");
+        return
+      }
+    }
+    this.setState({
+      loading: true,
+    });
+    $.ajax({
+      method: "POST",
+      dataType: "json",
+      crossDomain: false,
+      url: globalConfig.context + "/api/admin/orderProject/updateMemberProject",
+      data: {
+        id: this.state.fid, //任务ID
+        commodityId: this.state.commodityId, //项目ID
+        commodityName: this.state.commodityName, //项目名称
+        orderNo: this.props.orderNo, //订单编号
+        commodityQuantity: this.state.commodityQuantity, //数量
+        taskComment: this.state.taskComment, //备注
+        memberType: this.state.memberType,//会员付款状态
+        yearSum: this.state.yearSum,//会员总服务年限
+        serviceLife: JSON.stringify(this.state.serviceLife),//会员服务年限
+        serviceYear: this.state.serviceYear,//本次派单
+        contractTerm: JSON.stringify(this.state.contractTerm),//合同期
+        pictureUrl: pictureUrl.length ? pictureUrl : "",//附件
+      },
+    }).done(
+      function (data) {
+        this.setState({
+          loading: false,
+        });
+        if (!data.error.length) {
+          message.success("保存成功!");
+          this.props.onCancel();
+        } else {
+          message.warning(data.error[0].message);
+        }
+      }.bind(this)
+    );
+  }
   //
   httpChange(e) {
     this.setState({
@@ -289,12 +373,12 @@ class ProjectOperationVip extends Component {
       }.bind(this)
     );
   }
-  //上级主管输入框失去焦点是判断客户是否存在
+  //
   selectAuto(value) {
     const { customerArr } = this.state;
     const { newData } = this.props
     const newdataSources = JSON.stringify(customerArr) == "{}" ? [] : customerArr;
-    let cid = newdataSources.find((item) => item.commodityName == value).commodityId
+    let cid = newdataSources.find((item) => item.bname == value).commodityId
     this.setState({
       commodityName: value,
       commodityId: cid,
@@ -310,57 +394,57 @@ class ProjectOperationVip extends Component {
       this.setState({
         histYear: llist
       })
-      for (var j = newData.length - 1; j >= 0; j--) {
-        if (newData[j].commodityId == cid) {
+      for (var i = newData.length - 1; i >= 0; i--) {
+        if (newData[i].commodityId == cid) {
           this.setState({
-            memberType: !newData[j].memberType ? undefined : newData[j].memberType.toString(), // 付款情况
-            yearSum: newData[j].yearSum.toString(), // 会员总服务年限
-            serviceLife: !newData[j].serviceLife ? [] : JSON.parse(newData[j].serviceLife), // 会员服务年限
-            contractTerm: !newData[j].contractTerm ? [] : JSON.parse(newData[j].contractTerm), // 合同期
-            taskComment: newData[j].taskComment, // 项目说明
-            // isEdit: true, // 不可编辑
-            isEdit: true, // 同一会员项目有且只有一条时可编辑   其他情况不可编辑
-            cPeriod: !newData[j].contractTerm ? false : true, //合同期
+            yearSum: newData[i].yearSum.toString(), // 会员总服务年限
+            serviceLife: JSON.parse(newData[i].serviceLife) || [], // 会员服务年限
+            isEdit: true, // 不可编辑
+            cPeriod: !newData[i].contractTerm ? false : true, //合同期编辑
           })
-          return
         } else {
           this.setState({
             yearSum: undefined,
             serviceLife: [],
-            contractTerm: [],
-            taskComment: undefined,
             isEdit: false, // 可编辑
             cPeriod: false,
           })
         }
+        return
       }
     }
   }
 
   handleClose(removedTag) {
     let serviceLife = this.state.serviceLife.filter(tag => { return tag !== removedTag });
-    this.setState({ serviceLife, serviceYear: undefined });
+    this.setState({
+      serviceLife,
+      // commodityQuantity: serviceLife.length == 0 ? undefined : serviceLife.length,
+      yearSum: serviceLife.length == 0 ? undefined : serviceLife.length.toString(),
+      serviceYear: undefined
+    });
   }
 
 
   render() {
     let options = this.state.customerArr.map((group, index) => (
-      <Select.Option key={index} value={group.commodityName}>
-        {group.commodityName}
+      <Select.Option key={index} value={group.bname}>
+        {group.bname}
       </Select.Option>
     ));
-    let contList = vipYear.map(its => (
-      <Option key={its}>{its}</Option>
-    ));
+    // let contList = vipYear.map(its => (
+    //   <Option key={its}>{its}</Option>
+    // ));
     const { readOnly } = this.props;
-    const { histYear, isEdit } = this.state
+    const { histYear, isEdit, cPeriod } = this.state
+    const { RangePicker } = DatePicker;
     return (
       <Modal
         maskClosable={false}
         visible={this.props.visible}
         onOk={this.props.onCancel}
         onCancel={this.props.onCancel}
-        width="1200px"
+        width="900px"
         title={readOnly ? "会员详情" : !this.state.fid ? "添加会员项目" : "编辑会员项目"}
         footer=""
         className="admin-desc-content"
@@ -376,29 +460,20 @@ class ProjectOperationVip extends Component {
                 label="服务名称"
               >
                 {readOnly ? this.state.commodityName :
-                  // <AutoComplete
-                  //   className="certain-category-search"
-                  //   dropdownClassName="certain-category-search-dropdown"
-                  //   dropdownMatchSelectWidth={false}
-                  //   style={{ width: "200px" }}
-                  //   dataSource={options}
-                  //   placeholder="输入服务名称"
-                  //   value={this.state.commodityName}
-                  //   onChange={this.httpChange}
-                  //   filterOption={true}
-                  //   onSelect={this.selectAuto}
-                  // >
-                  //   <Input />
-                  // </AutoComplete>
-                  <Select
-                    style={{ width: '200px' }}
+                  <AutoComplete
+                    className="certain-category-search"
+                    dropdownClassName="certain-category-search-dropdown"
+                    dropdownMatchSelectWidth={false}
+                    style={{ width: "200px" }}
+                    dataSource={options}
                     placeholder="输入服务名称"
                     value={this.state.commodityName}
-                    onChange={this.selectAuto}
+                    onChange={this.httpChange}
+                    filterOption={true}
+                    onSelect={this.selectAuto}
                   >
-                    {options}
-                  </Select>
-                }
+                    <Input />
+                  </AutoComplete>}
                 {!readOnly && <span className="mandatory">*</span>}
               </FormItem>
               <FormItem
@@ -449,7 +524,7 @@ class ProjectOperationVip extends Component {
                       { value: "1", key: "已付部分期款,需特批" },
                       { value: "2", key: "未付款,需特批" }].map(function (item) {
                         return (
-                          <Select.Option key={item.value}>
+                          <Select.Option key={item.value} value={item.value}>
                             {item.key}
                           </Select.Option>
                         );
@@ -462,8 +537,8 @@ class ProjectOperationVip extends Component {
                 {...formItemLayout}
                 label="会员总服务年限"
               >
-                {readOnly ?
-                  !this.state.yearSum ? "" :
+                {
+                  this.state.yearSum == null ? "" :
                     [
                       { value: "0", key: "" },
                       { value: "1", key: "一年" },
@@ -471,35 +546,8 @@ class ProjectOperationVip extends Component {
                       { value: "3", key: "三年" },
                       { value: "4", key: "四年" },
                       { value: "5", key: "五年" },
-                    ][this.state.yearSum]["key"] :
-                  <Select
-                    placeholder="请选择会员总服务年限"
-                    disabled={isEdit}
-                    style={{ width: "200px" }}
-                    value={this.state.yearSum}
-                    onChange={(e) => {
-                      this.setState({
-                        yearSum: e,
-                        serviceLife: [],
-                        serviceYear: undefined,
-                      });
-                    }}
-                  >
-                    {[
-                      { value: "1", key: "一年" },
-                      { value: "2", key: "二年" },
-                      { value: "3", key: "三年" },
-                      { value: "4", key: "四年" },
-                      { value: "5", key: "五年" },
-                    ].map(function (item) {
-                      return (
-                        <Select.Option key={item.value}>
-                          {item.key}
-                        </Select.Option>
-                      );
-                    })}
-                  </Select>}
-                {!readOnly && <span className="mandatory">*</span>}
+                    ][this.state.yearSum]["key"]
+                }
               </FormItem>
               <FormItem
                 className="half-item"
@@ -515,7 +563,7 @@ class ProjectOperationVip extends Component {
                     )
                   }
                   {
-                    !isEdit && (this.state.serviceLife.length < this.state.yearSum) &&
+                    !isEdit && (this.state.serviceLife.length < 5) &&
                     <Button
                       size="small"
                       type="primary"
@@ -551,31 +599,35 @@ class ProjectOperationVip extends Component {
                 } */}
                 {/* {!readOnly && <span className="mandatory">*</span>} */}
               </FormItem>
-              <FormItem
-                className="half-item"
-                {...formItemLayout}
-                label="本次派单"
-              >
-                {readOnly ?
-                  this.state.serviceYear :
-                  <Select
-                    placeholder="请选择本次派单年份"
-                    style={{ width: "200px" }}
-                    value={this.state.serviceYear}
-                    onChange={(e) => {
-                      this.setState({ serviceYear: e });
-                    }}
-                  >
-                    {this.state.serviceLife.length > 0 && this.state.serviceLife.map(function (item) {
-                      return (
-                        <Select.Option key={item} disabled={histYear.includes(item)}>
-                          {item}
-                        </Select.Option>
-                      );
-                    })}
-                  </Select>}
-                {!readOnly && <span className="mandatory">*</span>}
-              </FormItem>
+              {
+                this.state.serviceLife.length > 0 &&
+                <FormItem
+                  className="half-item"
+                  {...formItemLayout}
+                  label="本次派单"
+                >
+                  {readOnly ?
+                    this.state.serviceYear :
+                    <Select
+                      placeholder="请选择本次派单年份"
+                      style={{ width: "200px" }}
+                      value={this.state.serviceYear}
+                      onChange={(e) => {
+                        console.log("==", e)
+                        this.setState({ serviceYear: e });
+                      }}
+                    >
+                      {this.state.serviceLife.length > 0 && this.state.serviceLife.map(function (item) {
+                        return (
+                          <Select.Option key={item} disabled={histYear.includes(item)}>
+                            {item}
+                          </Select.Option>
+                        );
+                      })}
+                    </Select>}
+                  {!readOnly && <span className="mandatory">*</span>}
+                </FormItem>
+              }
               <FormItem
                 className="half-item"
                 {...formItemLayout}
@@ -583,21 +635,37 @@ class ProjectOperationVip extends Component {
               >
                 {
                   readOnly ?
-                    this.state.contractTerm.toString() :
-                    <Select
-                      mode="multiple"
-                      style={{ width: '200px' }}
-                      placeholder="请选择合同期"
-                      disabled={this.state.cPeriod}
-                      value={this.state.contractTerm}
-                      onChange={e => {
-                        this.setState({
-                          contractTerm: e,
-                        })
+                    !!this.state.contractTerm ? this.state.contractTerm.toString().replace(",", "至") : "" :
+                    <RangePicker
+                      style={{ width: 200 }}
+                      disabled={cPeriod}
+                      value={[
+                        this.state.contractTerm[0]
+                          ? moment(this.state.contractTerm[0])
+                          : null,
+                        this.state.contractTerm[1]
+                          ? moment(this.state.contractTerm[1])
+                          : null,
+                      ]}
+                      onChange={(data, dataString) => {
+                        this.setState({ contractTerm: dataString });
                       }}
-                    >
-                      {contList}
-                    </Select>
+                    />
+
+                  // <Select
+                  //   mode="multiple"
+                  //   style={{ width: '200px' }}
+                  //   placeholder="请选择合同期"
+                  //   disabled={this.state.cPeriod}
+                  //   value={this.state.contractTerm}
+                  //   onChange={e => {
+                  //     this.setState({
+                  //       contractTerm: e,
+                  //     })
+                  //   }}
+                  // >
+                  //   {contList}
+                  // </Select>
                 }
                 {!readOnly && <span className="mandatory">*</span>}
               </FormItem>
@@ -631,7 +699,7 @@ class ProjectOperationVip extends Component {
                   {readOnly ? this.state.taskComment :
                     <Input
                       type="textarea"
-                      placeholder=""
+                      placeholder="如:派2022年会员服务,总会员服务三年,客户付款情况说明"
                       autosize={{ minRows: 4 }}
                       value={this.state.taskComment}
                       onChange={(e) => {
@@ -639,10 +707,10 @@ class ProjectOperationVip extends Component {
                       }}
                     />}
                 </FormItem>
-                {/* <div style={{ color: "red", marginLeft: 144 }}>
+                <div style={{ color: "red", marginLeft: 144 }}>
                   请详细说明项目服务时间,总服务时间及付款情况,如:<span style={{ color: "#333" }}>派2022年会员服务,总会员服务三年,客户付款情况说明</span>
                   <p>未付款时,需进行特批审核,请详细说明预计付款时间等详细情况</p>
-                </div> */}
+                </div>
               </div>
               {readOnly ? null : <FormItem
                 wrapperCol={{ span: 12, offset: 4 }}
@@ -655,7 +723,7 @@ class ProjectOperationVip extends Component {
                     if (!this.state.fid) {
                       this.onSubmit()
                     } else {
-                      // this.onChange()
+                      this.onChange()
                     }
                   }}
                 >
@@ -696,6 +764,7 @@ class ProjectOperationVip extends Component {
               }
               this.setState({
                 serviceLife: slist,
+                yearSum: slist.length.toString(),
                 addYears: false
               })
             }}
@@ -716,10 +785,10 @@ class ProjectOperationVip extends Component {
             >
               {
                 vipYear.map(its => (
-                  <Option
+                  <Select.Option
                     key={its}
                     disabled={this.state.serviceLife.toString().includes(its)}
-                  >{its}</Option>
+                  >{its}</Select.Option>
                 ))
               }
             </Select>
@@ -741,4 +810,4 @@ class ProjectOperationVip extends Component {
   }
 }
 
-export default ProjectOperationVip;
+export default ProjectOperationVip;

+ 1 - 1
js/component/manageCenter/order/orderNew/myprojectvip.jsx

@@ -7,7 +7,7 @@ import { ChooseList } from "../../order/orderNew/chooseList"
 import ReactToPrint from "react-to-print";
 import OrderItemStatus from "../../../common/orderItemStatus";
 import { salesList } from "@/dataDic.js";
-import ProjectOperationVip from ".././../../common/projectOperation/vip";
+import ProjectOperationVip from "../../../common/projectOperation/vip";
 import ShowModalDiv from "@/showModal.jsx";
 import VipLogs from "../../../common/logPopup/viplogs";//会员日志
 import { splitUrl } from "@/tools";

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "afanti",
-  "version": "1.2.85",
+  "version": "1.2.86",
   "description": "",
   "main": "index.js",
   "scripts": {