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
<script lang="ts" setup>
import { useModal } from '@jnpf/ui/modal';
 
import { InterfaceModal } from '#/components/CommonModal';
import { SelectInterfaceBtn } from '#/components/Interface';
 
import { dataTypeList } from '../helper/dataMap';
import JsonModal from './RJsonModal.vue';
import Refresh from './RRefresh.vue';
 
const props = defineProps(['activeData', 'showType', 'mapOptions']);
const [registerJson, { openModal: openJsonModal }] = useModal();
 
function renderKeyChange() {
  props.activeData.renderKey = Date.now();
}
function dataTypeChange() {
  props.activeData.propsApi = '';
  props.activeData.propsName = '';
  props.activeData.templateJson = [];
  renderKeyChange();
}
function appDataTypeChange() {
  props.activeData.appPropsApi = '';
  props.activeData.appPropsName = '';
  props.activeData.appTemplateJson = [];
  renderKeyChange();
}
function onPropsApiChange(val, item) {
  if (val) {
    props.activeData.propsApi = val;
    props.activeData.propsName = item.fullName;
    props.activeData.refresh.autoRefresh = false;
    props.activeData.templateJson = item.parameterJson ? JSON.parse(item.parameterJson).map((o) => ({ ...o, relationField: '', sourceType: 2 })) : [];
  } else {
    props.activeData.propsApi = '';
    props.activeData.propsName = '';
    props.activeData.templateJson = [];
  }
  renderKeyChange();
}
function onAppPropsApiChange(val, item) {
  if (val) {
    props.activeData.appPropsApi = val;
    props.activeData.appPropsName = item.fullName;
    props.activeData.appRefresh.autoRefresh = false;
    props.activeData.appTemplateJson = item.parameterJson ? JSON.parse(item.parameterJson).map((o) => ({ ...o, relationField: '', sourceType: 2 })) : [];
  } else {
    props.activeData.appPropsApi = '';
    props.activeData.appPropsName = '';
    props.activeData.appTemplateJson = [];
  }
  renderKeyChange();
}
function showData(val) {
  openJsonModal(true, { value: JSON.stringify(val) });
}
function handleRefreshData(data) {
  props.activeData.option = data ? JSON.parse(data) : [];
  renderKeyChange();
}
</script>
<template>
  <a-collapse-panel>
    <template #header>自定义设置</template>
    <template v-if="showType === 'pc'">
      <a-form-item label="数据类型">
        <jnpf-radio v-model:value="activeData.dataType" :options="dataTypeList" option-type="button" button-style="solid" @change="dataTypeChange" />
      </a-form-item>
      <a-form-item label="数据设置" v-if="activeData.dataType === 'static'">
        <a-button @click="showData(activeData.option)">设置</a-button>
      </a-form-item>
      <template v-if="activeData.dataType === 'dynamic'">
        <a-form-item label="数据接口">
          <InterfaceModal :value="activeData.propsApi" :title="activeData.propsName" popup-title="数据接口" @change="onPropsApiChange" />
        </a-form-item>
        <a-form-item label="参数设置" v-if="activeData.templateJson?.length">
          <SelectInterfaceBtn :template-json="activeData.templateJson" :show-system-form-id="false" :type="2" />
        </a-form-item>
        <Refresh v-if="activeData.propsApi" :refresh="activeData.refresh" />
      </template>
    </template>
    <template v-else>
      <a-form-item label="数据类型">
        <jnpf-radio v-model:value="activeData.appDataType" :options="dataTypeList" option-type="button" button-style="solid" @change="appDataTypeChange" />
      </a-form-item>
      <a-form-item label="数据设置" v-if="activeData.appDataType === 'static'">
        <a-button @click="showData(activeData.appOption)">设置</a-button>
      </a-form-item>
      <template v-if="activeData.appDataType === 'dynamic'">
        <a-form-item label="数据接口">
          <InterfaceModal :value="activeData.appPropsApi" :title="activeData.appPropsName" popup-title="数据接口" @change="onAppPropsApiChange" />
        </a-form-item>
        <a-form-item label="参数设置" v-if="activeData.appTemplateJson?.length">
          <SelectInterfaceBtn :template-json="activeData.appTemplateJson" :show-system-form-id="false" :type="2" />
        </a-form-item>
        <Refresh v-if="activeData.appPropsApi" :refresh="activeData.appRefresh" />
      </template>
    </template>
    <JsonModal @register="registerJson" @change="handleRefreshData" />
  </a-collapse-panel>
</template>