hejianhao
2026-03-04 af1b2b512ccdd828c82b899bcb9e16cc1c05064a
fix: 修复A类资产规则编辑界面错误显示OR条件的问题

根据业务需求,A类资产不应显示OR条件编辑功能。通过条件渲染仅在B类和C类资产中显示“添加OR条件”按钮及相关编辑组件。
1个文件已修改
154 ■■■■■ 已修改文件
estate-frontend-v2024/src/views/business/forms/edit-clientParams-form.jsx 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
estate-frontend-v2024/src/views/business/forms/edit-clientParams-form.jsx
@@ -689,86 +689,90 @@
                          style={{ marginTop: 12 }}
                        >
                          <div className="label">{['A', 'B', 'C'][index]}类:</div>
                          <div>
                            <Button
                              type="primary"
                              onClick={() => this.addOrCondition(type)}
                              size="small"
                            >
                              添加OR条件
                            </Button>
                            {assetRules[type].map((orGroup, orIndex) => (
                              <div
                                key={orIndex}
                                style={{
                                  display: 'flex',
                                  alignItems: "center",
                                  flexWrap: "wrap",
                                  marginTop: 5
                                }}
                                className="flex"
                          {
                            type != 'a' &&
                            <div>
                              <Button
                                type="primary"
                                onClick={() => this.addOrCondition(type)}
                                size="small"
                              >
                                {orIndex > 0 && (
                                  <div style={{ display: 'flex', alignItems: 'center' }}>
                                    <span style={{ color: "#ff4d4f", margin: '0 5px' }}>OR</span>
                                    <Icon
                                      type="delete"
                                      style={{ fontSize: 18, color: "#FF4D4F", cursor: "pointer", marginRight: 8 }}
                                      onClick={() => this.removeOrCondition(type, orIndex)}
                                    />
                                  </div>
                                )}
                                添加OR条件
                              </Button>
                                <div style={{ border: '1px dashed #ccc', padding: 5, borderRadius: 4, display: 'flex', flexWrap: 'wrap', alignItems: 'center' }}>
                                  {orGroup.map((andItem, andIndex) => {
                                    const level = Object.keys(andItem)[0];
                                    const quantity = andItem[level];
                                    return (
                                    <div key={andIndex} style={{ display: "flex", alignItems: "center", margin: '2px 0' }}>
                                      {andIndex > 0 && (
                                        <div style={{ display: 'flex', alignItems: 'center' }}>
                                          <span style={{ marginLeft: 8, color: "#999" }}>and</span>
                                          <Icon
                                            type="minus-circle"
                                            theme="filled"
                                            style={{ marginLeft: 4, fontSize: 16, color: "#FF4D4F", cursor: "pointer", marginRight: 4 }}
                                            onClick={() => this.removeAndCondition(type, orIndex, andIndex)}
                                          />
                                        </div>
                                      )}
                                      <Select
                                        style={{ width: 120 }}
                                        placeholder="隐患级别"
                                        value={level ? Number(level) : undefined}
                                        onChange={(val) => this.updateCondition(type, orIndex, andIndex, "level", val)}
                                      >
                                        <Option value={1}>一级隐患</Option>
                                        <Option value={2}>二级隐患</Option>
                                        <Option value={3}>三级隐患</Option>
                                        <Option value={4}>四级隐患</Option>
                                      </Select>
                                      <Input
                                        style={{ width: 80, marginLeft: 8 }}
                                        type="number"
                                        placeholder="数量"
                                        value={quantity}
                                        disabled={!level}
                                        onChange={(e) => this.updateCondition(type, orIndex, andIndex, "quantity", e.target.value)}
                              {assetRules[type].map((orGroup, orIndex) => (
                                <div
                                  key={orIndex}
                                  style={{
                                    display: 'flex',
                                    alignItems: "center",
                                    flexWrap: "wrap",
                                    marginTop: 5
                                  }}
                                  className="flex"
                                >
                                  {orIndex > 0 && (
                                    <div style={{ display: 'flex', alignItems: 'center' }}>
                                      <span style={{ color: "#ff4d4f", margin: '0 5px' }}>OR</span>
                                      <Icon
                                        type="delete"
                                        style={{ fontSize: 18, color: "#FF4D4F", cursor: "pointer", marginRight: 8 }}
                                        onClick={() => this.removeOrCondition(type, orIndex)}
                                      />
                                    </div>
                                  )})}
                                  <Icon
                                    type="plus-circle"
                                    theme="filled"
                                    style={{ marginLeft: 8, fontSize: 18, color: "#1DA57A", cursor: "pointer" }}
                                    onClick={() => this.addAndCondition(type, orIndex)}
                                  />
                                  )}
                                  <div style={{ border: '1px dashed #ccc', padding: 5, borderRadius: 4, display: 'flex', flexWrap: 'wrap', alignItems: 'center' }}>
                                    {orGroup.map((andItem, andIndex) => {
                                      const level = Object.keys(andItem)[0];
                                      const quantity = andItem[level];
                                      return (
                                        <div key={andIndex} style={{ display: "flex", alignItems: "center", margin: '2px 0' }}>
                                          {andIndex > 0 && (
                                            <div style={{ display: 'flex', alignItems: 'center' }}>
                                              <span style={{ marginLeft: 8, color: "#999" }}>and</span>
                                              <Icon
                                                type="minus-circle"
                                                theme="filled"
                                                style={{ marginLeft: 4, fontSize: 16, color: "#FF4D4F", cursor: "pointer", marginRight: 4 }}
                                                onClick={() => this.removeAndCondition(type, orIndex, andIndex)}
                                              />
                                            </div>
                                          )}
                                          <Select
                                            style={{ width: 120 }}
                                            placeholder="隐患级别"
                                            value={level ? Number(level) : undefined}
                                            onChange={(val) => this.updateCondition(type, orIndex, andIndex, "level", val)}
                                          >
                                            <Option value={1}>一级隐患</Option>
                                            <Option value={2}>二级隐患</Option>
                                            <Option value={3}>三级隐患</Option>
                                            <Option value={4}>四级隐患</Option>
                                          </Select>
                                          <Input
                                            style={{ width: 80, marginLeft: 8 }}
                                            type="number"
                                            placeholder="数量"
                                            value={quantity}
                                            disabled={!level}
                                            onChange={(e) => this.updateCondition(type, orIndex, andIndex, "quantity", e.target.value)}
                                          />
                                        </div>
                                      )
                                    })}
                                    <Icon
                                      type="plus-circle"
                                      theme="filled"
                                      style={{ marginLeft: 8, fontSize: 18, color: "#1DA57A", cursor: "pointer" }}
                                      onClick={() => this.addAndCondition(type, orIndex)}
                                    />
                                  </div>
                                </div>
                              </div>
                            ))}
                          </div>
                              ))}
                            </div>
                          }
                        </div>
                      ))}
                    </div>