ny
昨天 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
<script lang="ts" setup>
import { computed, watch } from 'vue';
 
import { useModal } from '@jnpf/ui/modal';
 
import { cloneDeep } from 'lodash-es';
 
import MsgModal from '#/components/FlowProcess/src/propPanel/components/MsgModal.vue';
import MsgTemplateDetail from '#/components/FlowProcess/src/propPanel/components/MsgTemplateDetail.vue';
 
import HeaderContainer from './components/HeaderContainer.vue';
 
defineOptions({ inheritAttrs: false });
 
const props = defineProps(['formFieldsOptions', 'formConf', 'updateJnpfData', 'dataSourceForm', 'updateBpmnProperties']);
const [registerDetail, { openModal: openDetailModal }] = useModal();
const msgTemplateJsonColumns = [
  { title: '模板名称', dataIndex: 'msgTemplateName', key: 'msgTemplateName' },
  { title: '参数名称', dataIndex: 'paramJson', key: 'paramJson' },
  { title: '参数来源', dataIndex: 'sourceType', key: 'sourceType', width: 85 },
  { title: '参数值', dataIndex: 'field', key: 'field', width: 150 },
];
const sourceTypeOptions = [
  { id: 1, fullName: '字段' },
  { id: 2, fullName: '自定义' },
];
const allowList = [
  'organizeSelect',
  'posSelect',
  'userSelect',
  'usersSelect',
  'roleSelect',
  'groupSelect',
  'createUser',
  'modifyUser',
  'currOrganize',
  'currPosition',
];
const getUserDataSourceForm = computed(() => filterDataSourceForm(allowList));
 
watch(
  () => props.formConf,
  () => props.updateJnpfData(),
  { deep: true, immediate: true },
);
 
function onMsgChange(val, row) {
  if (!val) {
    props.formConf.msgId = '';
    props.formConf.msgName = '';
    props.formConf.msgTemplateJson = [];
    props.formConf.content = '';
    props.updateBpmnProperties('elementBodyName', '');
    return;
  }
  if (props.formConf.msgId === val) return;
  props.formConf.msgId = val;
  props.formConf.msgName = row.fullName;
  props.formConf.msgTemplateJson = (row.templateJson || []).map((o) => ({ ...o, paramJson: (o.paramJson || []).map((e) => ({ ...e, sourceType: 1 })) })) || [];
  props.formConf.content = `执行[${props.formConf.msgName}]的消息通知`;
  props.updateBpmnProperties('elementBodyName', props.formConf.content);
}
function onRelationFieldChange(val, row) {
  if (!val) return;
  const list = props.formFieldsOptions.filter((o) => o.id === val);
  if (!list.length) return;
  const item = list[0];
  row.isSubTable = item.__config__ && item.__config__.isSubTable ? item.__config__.isSubTable : false;
}
function goMsgDetail(id) {
  openDetailModal(true, { id });
}
function filterDataSourceForm(notSupportList) {
  return cloneDeep(props.dataSourceForm)
    .map((item) => ({
      ...item,
      children: item.children.filter((o) => o?.__config__?.jnpfKey && notSupportList.includes(o.__config__.jnpfKey)),
    }))
    .filter((item) => item.children?.length);
}
</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="接收人">
      <a-input-group compact>
        <jnpf-select v-model:value="formConf.msgUserIdsSourceType" :options="sourceTypeOptions" class="!w-[100px]" @change="formConf.msgUserIds = ''" />
        <div style="width: calc(100% - 100px)">
          <jnpf-select
            v-model:value="formConf.msgUserIds"
            :options="getUserDataSourceForm"
            :field-names="{ options: 'children' }"
            show-search
            allow-clear
            class="w-full"
            v-if="formConf.msgUserIdsSourceType == 1" />
          <jnpf-users-select v-model:value="formConf.msgUserIds" v-else />
        </div>
      </a-input-group>
    </a-form-item>
    <a-form-item label="通知内容">
      <div class="ant-form-item-label"><label class="ant-form-item-no-colon">发送配置</label></div>
      <MsgModal :value="formConf.msgId" :title="formConf.msgName" message-source="3" @change="(val, data) => onMsgChange(val, data)" />
      <div class="ant-form-item-label !mt-[12px]"><label class="ant-form-item-no-colon">参数设置</label></div>
      <a-table :data-source="formConf.msgTemplateJson" :columns="msgTemplateJsonColumns" size="small" :pagination="false">
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'msgTemplateName'">
            <p class="link-text !w-[80px]" @click="goMsgDetail(record.templateId)">{{ record.msgTemplateName }}</p>
          </template>
          <div v-for="(item, index) in record.paramJson" :key="index" :class="{ '!mt-[8px]': index > 0 }">
            <template v-if="column.key === 'paramJson'">
              <div class="parameter-box !w-[80px] leading-[32px]" :title="`${item.field}(${item.fieldName})`">{{ item.field }}({{ item.fieldName }})</div>
            </template>
            <template v-if="column.key === 'sourceType'">
              <jnpf-select class="!w-[75px]" v-model:value="item.sourceType" :options="sourceTypeOptions" @change="item.relationField = ''" />
            </template>
            <template v-if="column.key === 'field'">
              <jnpf-select
                v-model:value="item.relationField"
                :options="dataSourceForm"
                allow-clear
                show-search
                :field-names="{ options: 'children' }"
                option-label-prop="label"
                class="!w-[140px]"
                @change="onRelationFieldChange($event, item)"
                v-if="item.sourceType == 1" />
              <jnpf-input v-model:value="item.relationField" placeholder="请输入" v-else />
            </template>
          </div>
        </template>
        <template #emptyText>
          <p class="leading-[60px]">暂无数据</p>
        </template>
      </a-table>
    </a-form-item>
  </a-form>
  <MsgTemplateDetail @register="registerDetail" />
</template>