Skip to content

Commit

Permalink
bugfix: 修复文本值下拉框变量传递时值异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang authored and normal-wls committed Sep 6, 2023
1 parent 260675b commit a11dfb8
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions pipeline_plugins/variables/collections/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
"""

import datetime
import logging
import json
import logging
from typing import List

from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from pipeline.core.data.var import LazyVariable, RegisterVariableMeta, SpliceVariable
from pipeline.core.flow.io import IntItemSchema, StringItemSchema

from gcloud.conf import settings as gcloud_settings
from gcloud.constants import Type
from gcloud.core.models import StaffGroupSet
from gcloud.exceptions import ApiRequestError
from gcloud.utils.cmdb import get_notify_receivers
from gcloud.conf import settings as gcloud_settings
from pipeline.core.data.var import SpliceVariable, LazyVariable, RegisterVariableMeta
from pipeline.core.flow.io import StringItemSchema, IntItemSchema
from pipeline_plugins.base.utils.inject import supplier_account_for_business
from pipeline_plugins.variables.base import SelfExplainVariable, FieldExplain
from pipeline_plugins.variables.base import FieldExplain, SelfExplainVariable

logger = logging.getLogger("root")
get_client_by_user = gcloud_settings.ESB_GET_CLIENT_BY_USER
Expand Down Expand Up @@ -159,10 +159,9 @@ def _self_explain(cls, **kwargs) -> List[FieldExplain]:
]

def get_value(self):

meta_values = json.loads(self.value["meta_data"])
info_values = (
[self.value["info_value"]] if isinstance(self.value["info_value"], str) else self.value["info_value"]
)
info_values = TextValueSelect.process_info_value(self.value["info_value"])
text_values = [meta["text"] for meta in meta_values if meta["value"] in info_values]
text_not_selected_values = [meta["text"] for meta in meta_values if meta["value"] not in info_values]
info_not_selected_values = [meta["value"] for meta in meta_values if meta["value"] not in info_values]
Expand All @@ -174,6 +173,19 @@ def get_value(self):
"value_not_selected": ",".join(info_not_selected_values),
}

@classmethod
def process_info_value(cls, info_value):
if isinstance(info_value, str):
return [info_value]

# 在 子流程 变量传递的过程中,会出现info_value = {"value": 1, "text": "xx", "text_not_selected": "xx"}的情况,
# 所以需要特殊处理一下
if isinstance(info_value, dict):
if set(info_value.keys()) == {"value", "text", "text_not_selected", "value_not_selected"}:
return [info_value["value"]]

return info_value

@classmethod
def process_meta_value(self, meta_data, info_value):
if meta_data["value"]["datasource"] == "1":
Expand Down

0 comments on commit a11dfb8

Please sign in to comment.