ny
23 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<script lang="ts" setup>
import { computed, watch } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
import { useModal } from '@jnpf/ui/modal';
 
import { useClipboard } from '@vueuse/core';
 
import BatchModal from '#/components/FlowProcess/src/propPanel/components/BatchModal.vue';
import { useBaseStore } from '#/store';
 
import HeaderContainer from './components/HeaderContainer.vue';
import WebhookRequestModal from './components/WebhookRequestModal.vue';
 
defineOptions({ inheritAttrs: false });
 
const props = defineProps(['formFieldsOptions', 'formConf', 'updateJnpfData', 'updateBpmnProperties', 'flowInfo']);
const baseStore = useBaseStore();
const getSysConfig = computed(() => baseStore.sysConfigInfo);
const { createMessage } = useMessage();
const [registerBatchModal, { openModal: openBatchModal }] = useModal();
const [registerWebhookRequestModal, { openModal: openWebhookRequestModal }] = useModal();
const { copy } = useClipboard({ legacy: true });
watch(
  () => props.formConf,
  () => props.updateJnpfData(),
  { deep: true, immediate: true },
);
watch(
  () => props.formConf.formFieldList,
  (val) => {
    props.formConf.content = val?.length ? '已设置触发' : '';
    props.updateBpmnProperties('elementBodyName', props.formConf.content);
  },
  { deep: true, immediate: true },
);
 
function handleCopy(text) {
  copy(text);
  createMessage.success('复制成功');
}
function addItem() {
  props.formConf.formFieldList.push({ id: '', fullName: '', label: '' });
}
function onItemChange(item) {
  item.label = item.fullName ? `${item.id}(${item.fullName})` : item.id;
}
function delItem(index) {
  props.formConf.formFieldList.splice(index, 1);
}
function addItemForOther(data) {
  const list: any[] = data.map((o) => ({ ...o, label: o.fullName ? `${o.id}(${o.fullName})` : o.id }));
  if (!props.formConf.formFieldList.length) return (props.formConf.formFieldList = list);
  for (const e of list) {
    if (e.id) {
      const findIndex = props.formConf.formFieldList.findIndex((o) => o.id === e.id);
      findIndex === -1 ? props.formConf.formFieldList.push(e) : (props.formConf.formFieldList[findIndex] = e);
    } else {
      props.formConf.formFieldList.push(e);
    }
  }
}
</script>
<template>
  <HeaderContainer :form-conf="formConf" @on-node-name-change="updateBpmnProperties('nodeName', $event)" />
  <a-form :colon="false" :model="formConf" class="config-content" layout="vertical">
    <a-form-item label="webhook URL">
      <p class="common-tip mb-[10px]">系统生成的URL,用来接收请求字段!</p>
      <a-input :value="getSysConfig.jnpfDomain + formConf.webhookUrl" readonly>
        <template #addonAfter>
          <span class="cursor-pointer" @click="handleCopy(getSysConfig.jnpfDomain + formConf.webhookUrl)">复制链接</span>
        </template>
      </a-input>
    </a-form-item>
    <a-form-item label="添加接口字段">
      <div class="mb-[10px]">
        <span class="link-text mr-[20px] inline-block" @click="addItem"><i class="icon-ym icon-ym-btn-add text-[14px]mr-[4px]"></i>自定义添加</span>
        <span class="link-text mr-[20px] inline-block" @click="openBatchModal(true, {})">
          <i class="icon-ym icon-ym-btn-add text-[14px]mr-[4px]"></i>从JSON格式添加
        </span>
        <span
          class="link-text mr-[20px] inline-block"
          @click="
            openWebhookRequestModal(true, {
              url: formConf.webhookGetFieldsUrl,
              randomStr: formConf.webhookRandomStr,
              id: props.flowInfo.flowId,
              type: 'workFlow',
            })
          ">
          <i class="icon-ym icon-ym-btn-add text-[14px]mr-[4px]"></i>从请求接口添加
        </span>
      </div>
      <div class="condition-main">
        <div class="condition-list">
          <a-row :gutter="8" v-for="(item, index) in formConf.formFieldList" :key="index" class="mt-[10px]">
            <a-col :span="10">
              <a-input v-model:value="item.id" placeholder="字段" @change="onItemChange(item)" />
            </a-col>
            <a-col :span="13">
              <a-input v-model:value="item.fullName" placeholder="字段说明" @change="onItemChange(item)" />
            </a-col>
            <a-col :span="1" class="text-center">
              <i class="icon-ym icon-ym-btn-clearn" @click="delItem(index)"></i>
            </a-col>
          </a-row>
        </div>
      </div>
    </a-form-item>
  </a-form>
  <BatchModal @register="registerBatchModal" @confirm="addItemForOther" />
  <WebhookRequestModal @register="registerWebhookRequestModal" @confirm="addItemForOther" />
</template>