sort: Number()

in src/routes/Plugin/Common/Rule.js [234:560]


            sort: Number(values.sort),
            ruleConditions,
          });
        }
      }
    });
  };

  handleAdd = () => {
    let { ruleConditions } = this.state;
    ruleConditions.push({
      paramType: "uri",
      operator: "pathPattern",
      paramName: "/",
      paramValue: "",
    });

    this.setState({ ruleConditions }, () => {
      let len = ruleConditions.length || 0;
      let key = `paramTypeValueEn${len - 1}`;
      this.setState({ [key]: true });
    });
  };

  handleDelete = (index) => {
    let { ruleConditions } = this.state;
    if (ruleConditions && ruleConditions.length > 1) {
      ruleConditions.splice(index, 1);
    } else {
      message.destroy();
      message.error("At least one condition");
    }
    this.setState({ ruleConditions });
  };

  handleAddHandle = () => {
    let { pluginHandleList } = this.state;
    let pluginHandle = pluginHandleList[0];
    let toAddPluginHandle = pluginHandle.map((e) => {
      return { ...e, value: null };
    });
    pluginHandleList.push(toAddPluginHandle);
    this.setState({
      pluginHandleList,
    });
  };

  handleDeleteHandle = (index) => {
    let { pluginHandleList } = this.state;
    if (pluginHandleList.length === 1) {
      message.destroy();
      message.error(getIntlContent("SHENYU.PLUGIN.HANDLE.TIP"));
    } else {
      pluginHandleList.splice(index, 1);
      this.setState({ pluginHandleList });
    }
  };

  conditionChange = (index, name, value) => {
    let { ruleConditions } = this.state;
    ruleConditions[index][name] = value;
    if (name === "paramType") {
      let key = `paramTypeValueEn${index}`;
      if (
        value === "uri" ||
        value === "host" ||
        value === "ip" ||
        value === "req_method" ||
        value === "domain"
      ) {
        this.setState({ [key]: true });
        ruleConditions[index].paramName = "/";
      } else {
        this.setState({ [key]: false });
      }
      if (value === "post") {
        ruleConditions[index].paramName = "filedName";
      }
      if (value === "query") {
        ruleConditions[index].paramName = "paramName";
      }
      if (value === "header") {
        ruleConditions[index].paramName = "headerName";
      }
      if (value === "cookie") {
        ruleConditions[index].paramName = "cookieName";
      }
      if (value === "uri") {
        ruleConditions[index].operator = "pathPattern";
      } else if (value === "req_method") {
        ruleConditions[index].operator = "=";
      } else {
        ruleConditions[index].operator = "";
      }
    }

    this.setState({ ruleConditions });
  };

  handleCopyData = (copyData) => {
    if (!copyData) {
      this.setState({ visible: false });
      return;
    }
    const { form } = this.props;
    const { ruleConditions, name, matchMode, loged, enabled, sort } = copyData;
    const formData = {
      name,
      matchMode: matchMode.toString(),
      loged,
      enabled,
      sort,
    };
    this.initRuleCondition({
      ruleConditions: ruleConditions.map((v) => {
        const {
          id: rawId,
          selectorId,
          dateCreated,
          dateUpdated,
          ...condition
        } = v;
        return condition;
      }),
    });
    form.setFieldsValue(formData);
    this.setState({ visible: false });
  };

  renderOperatorOptions = (operators, paramType) => {
    if (operators && operators instanceof Array) {
      let operatorsFil = operators.map((operate) => {
        return (
          <Option key={operate.dictValue} value={operate.dictValue}>
            {operate.dictName}
          </Option>
        );
      });
      if (paramType !== "uri") {
        operatorsFil = operatorsFil.filter((operate) => {
          return operate.key !== "pathPattern" ? operate : "";
        });
      }
      if (
        paramType !== "post" &&
        paramType !== "query" &&
        paramType !== "header" &&
        paramType !== "cookie"
      ) {
        operatorsFil = operatorsFil.filter((operate) => {
          return operate.key !== "isBlank" ? operate : "";
        });
      }
      if (
        paramType === "uri" ||
        paramType === "host" ||
        paramType === "ip" ||
        paramType === "cookie" ||
        paramType === "domain"
      ) {
        operatorsFil = operatorsFil.filter((operate) => {
          return operate.key !== "TimeBefore" && operate.key !== "TimeAfter"
            ? operate
            : "";
        });
      }
      if (paramType === "req_method") {
        operatorsFil = operatorsFil.filter((operate) => {
          return operate.key === "=" ? operate : "";
        });
      }
      return operatorsFil;
    }

    return "";
  };

  getParamValueInput = (item, index) => {
    if (item.operator === "TimeBefore" || item.operator === "TimeAfter") {
      let date = new Date();
      const defaultDay = date
        .getFullYear()
        .toString()
        .concat("-")
        .concat(date.getMonth() + 1)
        .concat("-")
        .concat(date.getDate());
      return (
        <Input.Group compact style={{ top: -2 }}>
          <DatePicker
            style={{ width: "51%" }}
            onChange={(e) => {
              let day = e
                ? e
                    .eraYear()
                    .toString()
                    .concat("-")
                    .concat(e.month() + 1)
                    .concat("-")
                    .concat(e.date())
                : defaultDay;
              this.conditionChange(
                index,
                "paramValue",
                `${formatDateString(day)} ${formatTimeString(item.paramValue)}`,
              );
            }}
            value={formatDate(item.paramValue)}
          />
          <TimePicker
            style={{ width: "49%" }}
            onChange={(e) => {
              let time = e
                ? ""
                    .concat(" ")
                    .concat(e.hours())
                    .concat(":")
                    .concat(e.minutes())
                    .concat(":")
                    .concat(e.seconds())
                : "";
              this.conditionChange(
                index,
                "paramValue",
                `${formatDateString(item.paramValue)} ${formatTimeString(time)}`,
              );
            }}
            value={formatTime(item.paramValue)}
          />
        </Input.Group>
      );
    } else {
      return (
        <Input
          allowClear
          onChange={(e) => {
            this.conditionChange(index, "paramValue", e.target.value);
          }}
          value={item.paramValue}
        />
      );
    }
  };

  render() {
    let {
      onCancel,
      form,
      name = "",
      matchMode = "",
      loged = true,
      enabled = true,
      matchRestful = false,
      sort = "",
      multiRuleHandle,
      pluginName,
      handle,
    } = this.props;
    const {
      ruleConditions,
      pluginHandleList,
      operatorDics,
      matchModeDics,
      paramTypeDics,
      customRulePage,
      visible,
    } = this.state;

    let RuleHandleComponent;
    if (customRulePage) {
      RuleHandleComponent = ComposeRuleHandle;
    } else if (pluginHandleList) {
      RuleHandleComponent = CommonRuleHandle;
    }

    const { getFieldDecorator } = form;
    const formItemLayout = {
      labelCol: {
        sm: { span: 4 },
      },
      wrapperCol: {
        sm: { span: 20 },
      },
    };
    const formCheckLayout = {
      labelCol: {
        sm: { span: 18 },
      },
      wrapperCol: {
        sm: { span: 4 },
      },
    };
    return (
      <Modal
        width={1000}
        centered
        title={getIntlContent("SHENYU.RULE.NAME")}
        visible
        okText={getIntlContent("SHENYU.COMMON.SURE")}
        cancelText={getIntlContent("SHENYU.COMMON.CALCEL")}
        onOk={this.handleSubmit}
        onCancel={onCancel}
      >
        <Form onSubmit={this.handleSubmit} className="login-form">
          <FormItem
            label={getIntlContent("SHENYU.PLUGIN.SELECTOR.LIST.COLUMN.NAME")}
            {...formItemLayout}
          >
            {getFieldDecorator("name", {
              rules: [
                {
                  required: true,
                  message: getIntlContent("SHENYU.COMMON.INPUTNAME"),
                },
              ],
              initialValue: name,
            })(
              <Input
                allowClear
                placeholder={getIntlContent(
                  "SHENYU.PLUGIN.SELECTOR.LIST.COLUMN.NAME",
                )}
                addonAfter={
                  <Button
                    size="small"
                    type="link"
                    onClick={() => {