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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<script lang="ts" setup>
import { computed, nextTick, onMounted, ref, watch } from 'vue';
 
import { typeProcessing, typeTask } from '@jnpf/bpmn/config';
import { NodeUtils } from '@jnpf/bpmn/utils';
 
import ConditionMain from '#/components/ColumnDesign/src/components/ConditionMain.vue';
 
import FlowFormModal from './components/FlowFormModal.vue';
import HeaderContainer from './components/HeaderContainer.vue';
 
defineOptions({ inheritAttrs: false });
const props = defineProps([
  'formFieldsOptions',
  'formConf',
  'updateJnpfData',
  'bpmn',
  'getFormFieldList',
  'element',
  'updateFormFieldList',
  'updateBpmnProperties',
]);
 
defineExpose({ initCondition });
 
const triggerFormEventOptions = [
  { id: 1, fullName: '新增数据' },
  { id: 2, fullName: '修改数据' },
  { id: 3, fullName: '删除数据' },
];
const actionOptions = () => {
  const defaultOptions = [
    { id: 1, fullName: '同意' },
    { id: 2, fullName: '拒绝' },
    { id: 3, fullName: '退回' },
  ];
  const element = props.element && props.bpmn.get('elementRegistry')?.get(props.element.id);
  return element?.incoming?.[0]?.source?.wnType === typeProcessing
    ? [
        { id: 4, fullName: '确认办理' },
        { id: 3, fullName: '退回' },
      ]
    : defaultOptions;
};
const conditionMainRef = ref();
const isTrigger = ref<boolean>(false);
const getTriggerEventTips = computed(() => {
  if (props.formConf.triggerEvent === 2) return '通过流程的处置动作,触发执行后续流程';
  if (props.formConf.triggerEvent === 3) return '直接触发,执行后续流程';
  return '通过流程表单的增删改,触发执行后续流程';
});
const getUpdateFieldOptions = computed(() => props.formFieldsOptions.filter((o) => !o?.__config__?.isSubTable));
const triggerContext = computed(() => {
  const elementRegistry: any = props.bpmn.get('elementRegistry');
  const element = elementRegistry.get(props.element.id);
  let wnType = typeTask;
  if (element.incoming.length) wnType = element.incoming[0].source.wnType;
  return wnType === typeTask ? '审批事件' : '办理事件';
});
watch(
  () => props.formConf,
  () => props.updateJnpfData(),
  { deep: true, immediate: true },
);
watch(
  [() => props.formConf.formName, () => props.formConf.triggerEvent, () => props.formConf.triggerFormEvent, () => props.formConf.actionList],
  () => {
    let content = '';
    if (props.formConf.formName) {
      let triggerEvent: string | undefined = '空白事件';
      if (props.formConf.triggerEvent == 1) {
        triggerEvent = triggerFormEventOptions[props.formConf.triggerFormEvent - 1]?.fullName;
      } else if (props.formConf.triggerEvent == 2) {
        triggerEvent = props.formConf.actionList.map((o) => actionOptions().find((e) => e?.id == o)?.fullName).join('/');
      }
      content = `当[${props.formConf.formName}]表单[${triggerEvent}]时`;
    }
    props.formConf.content = content;
    props.updateBpmnProperties('elementBodyName', content);
  },
  { immediate: true },
);
 
function initCondition() {
  nextTick(() => {
    conditionMainRef.value?.init({
      conditionList: props.formConf.ruleList || [],
      matchLogic: props.formConf.ruleMatchLogic,
      fieldOptions: props.formFieldsOptions || [],
    });
  });
}
function onConditionConfirm(data) {
  props.formConf.ruleList = data.conditionList || [];
  props.formConf.ruleMatchLogic = data.matchLogic || [];
}
function onFormIdChange(id, item) {
  if (id && props.formConf.formId === id) return;
  if (!id) return handleNull();
  props.getFormFieldList(id, 'eventTriggerForm', false, false);
  props.formConf.formName = item.fullName;
  props.formConf.formId = id;
  props.formConf.ruleList = [];
  props.formConf.ruleMatchLogic = 'and';
  props.formConf.updateFieldList = [];
}
function handleNull() {
  props.formConf.formName = '';
  props.formConf.formId = '';
  props.formConf.ruleList = [];
  props.formConf.ruleMatchLogic = 'and';
  props.formConf.updateFieldList = [];
  props.updateFormFieldList();
  initCondition();
}
 
onMounted(() => {
  isTrigger.value = NodeUtils.isTriggerNode({ type: props.element.wnType });
});
</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="触发类型" v-if="isTrigger">
      <a-radio-group v-model:value="formConf.isAsync" class="common-radio">
        <a-radio :value="1">异步</a-radio>
        <a-radio :value="0">同步</a-radio>
      </a-radio-group>
      <div class="common-tip mt-[12px]">
        {{
          formConf.isAsync === 0 ? '与审批流程串行,下一审批节点等待任务流程结束。当事件执行失败审批流程终止' : '与审批流程并行,当事件执行失败审批流程继续流转'
        }}
      </div>
    </a-form-item>
    <a-form-item label="触发表单">
      <FlowFormModal :value="formConf.formId" :title="formConf.formName" :disabled="isTrigger" type="1" @change="onFormIdChange" />
    </a-form-item>
    <a-form-item label="触发事件">
      <a-radio-group v-model:value="formConf.triggerEvent" class="common-radio" v-if="isTrigger">
        <a-radio :value="2">{{ triggerContext }}</a-radio>
        <a-radio :value="3">空白事件</a-radio>
      </a-radio-group>
      <div class="common-tip py-[12px]" v-if="isTrigger">{{ getTriggerEventTips }}</div>
      <template v-if="formConf.triggerEvent === 1 || !isTrigger">
        <jnpf-radio class="leading-[32px]" v-model:value="formConf.triggerFormEvent" :options="triggerFormEventOptions" />
        <template v-if="formConf.triggerFormEvent === 2">
          <jnpf-select
            v-model:value="formConf.updateFieldList"
            :options="getUpdateFieldOptions"
            :field-names="{ options: 'options1' }"
            show-search
            allow-clear
            multiple />
          <div class="common-tip mt-[12px]">未选择表示任意字段修改都会触发,选择了表示指定字段修改时触发</div>
        </template>
      </template>
      <div class="countersign-cell" v-if="formConf.triggerEvent === 2">
        <span class="w-[60px]">当操作</span>
        <jnpf-select v-model:value="formConf.actionList" :options="actionOptions()" show-search allow-clear multiple />
        <span class="w-[60px]">时触发</span>
      </div>
    </a-form-item>
    <a-form-item label="触发条件" v-if="!isTrigger">
      <div class="common-tip mb-[12px]">满足以下条件,触发执行动作</div>
      <ConditionMain ref="conditionMainRef" bordered compact is-custom-field-value-type @confirm="onConditionConfirm" />
    </a-form-item>
  </a-form>
</template>