ny
22 小时以前 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
<script lang="ts" setup>
import { computed, reactive } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
 
import { cloneDeep } from 'lodash-es';
 
import { systemComponentsList } from '#/components/FormGenerator/src/helper/config';
 
interface State {
  assignList: any[];
  isSubFlow: number;
  childFieldOptions: any[];
}
 
defineOptions({ inheritAttrs: false });
 
const props = defineProps(['formConf', 'formFieldsOptions']);
 
const state = reactive<State>({
  assignList: [],
  isSubFlow: 0,
  childFieldOptions: [],
});
 
const { createMessage } = useMessage();
const [registerModal, { closeModal }] = useModalInner(init);
 
const getChildFieldOptions = computed(() => {
  const list = cloneDeep(state.isSubFlow ? state.childFieldOptions : props.formFieldsOptions);
  return list.filter((o) => !['table', ...systemComponentsList].includes(o?.__config__?.jnpfKey));
});
function init(data) {
  state.assignList = data.assignList || [];
  state.isSubFlow = data.isSubFlow || 0;
  state.childFieldOptions = data.childFieldOptions || [];
}
function addTransmitRule(i) {
  state.assignList[i].ruleList.push({
    parentField: '',
    childField: '',
    childFieldOptions: [],
  });
}
function delTransmitRule(i, cIndex) {
  state.assignList[i].ruleList.splice(cIndex, 1);
}
function handleSubmit() {
  let boo = true;
  for (let i = 0; i < state.assignList.length; i++) {
    const e = state.assignList[i];
    const ruleList = e.ruleList;
    for (const element of ruleList) {
      if (!element.parentField) {
        boo = false;
        createMessage.error(`请选择${e.title}的上节点字段`);
        break;
      }
      if (!element.childField) {
        boo = false;
        createMessage.error(`请选择${e.title}的本节点字段`);
        break;
      }
    }
  }
  if (!boo) return;
  props.formConf.assignList = state.assignList;
  state.assignList = [];
  closeModal();
}
</script>
 
<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="数据传递" :width="700" @ok="handleSubmit" class="rule-modal">
    <a-tabs size="small" class="node-tabs">
      <a-tab-pane :tab="item.title" v-for="(item, i) in state.assignList" :key="i">
        <div class="common-tip mb-[10px]">
          {{
            !!state.isSubFlow
              ? '当父流程流转到子流程时,将对应的上一节点表单字段赋值给子流程发起节点'
              : '当节点流转到本节点时,将对应的上一节点的字段赋值给本节点'
          }}
        </div>
        <a-row :gutter="10" v-for="(child, cIndex) in item.ruleList" :key="cIndex" class="mb-[10px]">
          <a-col :span="2" class="rule-cell">{{ !!state.isSubFlow ? '父流程' : '上节点' }}</a-col>
          <a-col :span="7" class="rule-cell">
            <jnpf-select
              v-model:value="child.parentField"
              :options="item.formFieldList"
              :field-names="{ options: 'children' }"
              show-search
              allow-clear
              class="!w-full" />
          </a-col>
          <a-col :span="4" class="rule-cell mid">赋值给</a-col>
          <a-col :span="2" class="rule-cell">{{ !!state.isSubFlow ? '子流程' : '本节点' }}</a-col>
          <a-col :span="7" class="rule-cell">
            <jnpf-select
              v-model:value="child.childField"
              :options="getChildFieldOptions"
              :field-names="{ options: 'options1' }"
              show-search
              allow-clear
              class="!w-full" />
          </a-col>
          <a-col :span="2" class="rule-cell">
            <a-button type="danger" @click="delTransmitRule(i, cIndex)"><i class="icon-ym icon-ym-nav-close"></i></a-button>
          </a-col>
        </a-row>
        <div class="table-add-action" @click="addTransmitRule(i)">
          <a-button type="link" pre-icon="icon-ym icon-ym-btn-add">新增规则</a-button>
        </div>
      </a-tab-pane>
    </a-tabs>
  </BasicModal>
</template>