Skip to content

Commit 6c9d6f9

Browse files
committed
fix: fix github#1988
--bug=1051321 --user=王孝刚 【github#1988】【应用】应用编排接入带用户输入参数的应用,选择后,再次进入应用,选择的参数消失了 https://www.tapd.cn/57709429/s/1643562 --bug=1051323 --user=王孝刚 【应用】创建应用报错 https://www.tapd.cn/57709429/s/1643571
1 parent 8db35c4 commit 6c9d6f9

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

apps/application/serializers/application_serializers.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from common.constants.authentication_type import AuthenticationType
3636
from common.db.search import get_dynamics_model, native_search, native_page_search
3737
from common.db.sql_execute import select_list
38-
from common.exception.app_exception import AppApiException, NotFound404, AppUnauthorizedFailed
38+
from common.exception.app_exception import AppApiException, NotFound404, AppUnauthorizedFailed, ChatException
3939
from common.field.common import UploadedImageField, UploadedFileField
4040
from common.models.db_model_manage import DBModelManage
4141
from common.response import result
@@ -268,7 +268,8 @@ def get_embed(self, with_valid=True, params=None):
268268
float_location = application_setting.float_location
269269
if application_setting.custom_theme is not None and len(
270270
application_setting.custom_theme.get('header_font_color', 'rgb(100, 106, 115)')) > 0:
271-
header_font_color = application_setting.custom_theme.get('header_font_color', 'rgb(100, 106, 115)')
271+
header_font_color = application_setting.custom_theme.get('header_font_color',
272+
'rgb(100, 106, 115)')
272273

273274
is_auth = 'true' if application_access_token is not None and application_access_token.is_active else 'false'
274275
t = Template(content)
@@ -916,6 +917,12 @@ def profile(self, with_valid=True):
916917
if application_access_token is None:
917918
raise AppUnauthorizedFailed(500, "非法用户")
918919
application_setting_model = DBModelManage.get_model('application_setting')
920+
if application.type == ApplicationTypeChoices.WORK_FLOW:
921+
work_flow_version = QuerySet(WorkFlowVersion).filter(application_id=application.id).order_by(
922+
'-create_time')[0:1].first()
923+
if work_flow_version is not None:
924+
application.work_flow = work_flow_version.work_flow
925+
919926
xpack_cache = DBModelManage.get_model('xpack_cache')
920927
X_PACK_LICENSE_IS_VALID = False if xpack_cache is None else xpack_cache.get('XPACK_LICENSE_IS_VALID', False)
921928
application_setting_dict = {}
@@ -1150,9 +1157,23 @@ def application_list(self, with_valid=True):
11501157
def get_application(self, app_id, with_valid=True):
11511158
if with_valid:
11521159
self.is_valid(raise_exception=True)
1153-
application = QuerySet(Application).filter(id=self.data.get("application_id")).first()
1154-
return ApplicationSerializer.Operate(data={'user_id': application.user_id, 'application_id': app_id}).one(
1155-
with_valid=True)
1160+
if with_valid:
1161+
self.is_valid()
1162+
embed_application = QuerySet(Application).get(id=app_id)
1163+
if embed_application.type == ApplicationTypeChoices.WORK_FLOW:
1164+
work_flow_version = QuerySet(WorkFlowVersion).filter(application_id=embed_application.id).order_by(
1165+
'-create_time')[0:1].first()
1166+
if work_flow_version is not None:
1167+
embed_application.work_flow = work_flow_version.work_flow
1168+
dataset_list = self.list_dataset(with_valid=False)
1169+
mapping_dataset_id_list = [adm.dataset_id for adm in
1170+
QuerySet(ApplicationDatasetMapping).filter(application_id=app_id)]
1171+
dataset_id_list = [d.get('id') for d in
1172+
list(filter(lambda row: mapping_dataset_id_list.__contains__(row.get('id')),
1173+
dataset_list))]
1174+
self.update_search_node(embed_application.work_flow, [str(dataset.get('id')) for dataset in dataset_list])
1175+
return {**ApplicationSerializer.Query.reset_application(ApplicationSerializerModel(embed_application).data),
1176+
'dataset_id_list': dataset_id_list}
11561177

11571178
class ApplicationKeySerializerModel(serializers.ModelSerializer):
11581179
class Meta:

ui/src/workflow/nodes/application-node/index.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ const update_field = () => {
202202
.then((ok) => {
203203
const old_api_input_field_list = props.nodeModel.properties.node_data.api_input_field_list
204204
const old_user_input_field_list = props.nodeModel.properties.node_data.user_input_field_list
205-
206205
if (isWorkFlow(ok.data.type)) {
207206
const nodeData = ok.data.work_flow.nodes[0].properties.node_data
208207
const new_api_input_field_list = ok.data.work_flow.nodes[0].properties.api_input_field_list
@@ -213,7 +212,13 @@ const update_field = () => {
213212
(old_item: any) => old_item.variable == item.variable
214213
)
215214
if (find_field) {
216-
return { ...item, default_value: JSON.parse(JSON.stringify(find_field.default_value)) }
215+
return {
216+
...item,
217+
default_value: JSON.parse(JSON.stringify(find_field.default_value)),
218+
value: JSON.parse(JSON.stringify(find_field.value)),
219+
label:
220+
typeof item.label === 'object' && item.label != null ? item.label.label : item.label
221+
}
217222
} else {
218223
return item
219224
}
@@ -228,12 +233,17 @@ const update_field = () => {
228233
(old_item: any) => old_item.field == item.field
229234
)
230235
if (find_field) {
231-
return { ...item, default_value: JSON.parse(JSON.stringify(find_field.default_value)) }
236+
return {
237+
...item,
238+
default_value: JSON.parse(JSON.stringify(find_field.default_value)),
239+
value: JSON.parse(JSON.stringify(find_field.value)),
240+
label:
241+
typeof item.label === 'object' && item.label != null ? item.label.label : item.label
242+
}
232243
} else {
233244
return item
234245
}
235246
})
236-
console.log(merge_user_input_field_list)
237247
set(
238248
props.nodeModel.properties.node_data,
239249
'user_input_field_list',

0 commit comments

Comments
 (0)