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
<script lang="ts" setup>
import type { BasicColumn } from '@jnpf/ui/vxeTable';
 
import { computed } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
import { BasicVxeTable, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { $t } from '#/locales';
 
const props = defineProps({
  list: { type: Array as any, default: () => [] },
  activeStep: { type: Number, default: 0 },
  hasPage: { type: Number, default: 0 },
  sourceDisabled: { type: Boolean, default: false },
  fieldTreeData: { type: Array, default: () => [] },
  parameterJson: { type: Array, default: () => [] },
});
const { createConfirm } = useMessage();
const typeList = [
  { fullName: '字符串', id: 'varchar' },
  { fullName: '整型', id: 'int' },
  { fullName: '日期时间', id: 'datetime' },
  { fullName: '浮点', id: 'decimal' },
];
const pageParameters = [{ field: 'currentPage' }, { field: 'pageSize' }, { field: 'keyword' }];
const echoParameters = [{ field: 'showKey' }, { field: 'showValue' }];
 
const columns: BasicColumn[] = [
  { title: '参数名', dataIndex: 'field', slots: { default: 'field' } },
  { title: '类型', dataIndex: 'dataType', slots: { default: 'dataType' } },
  { title: '来源', dataIndex: 'source', slots: { default: 'source' } },
  { title: '参数值', dataIndex: 'defaultValue', slots: { default: 'defaultValue' } },
  { title: '操作', dataIndex: 'action', width: 50, slots: { default: 'action' } },
];
const [registerTable] = useVxeTable({
  columns,
  showIndexColumn: false,
  immediate: false,
  pagination: false,
  useSearchForm: false,
  showTableSetting: false,
});
 
const getSourceList = computed(() => {
  const list = [
    { fullName: '变量', id: 2 },
    { fullName: '自定义', id: 3 },
  ];
  const parameter = { fullName: '接口参数', id: 1 };
  const page = { fullName: '分页参数', id: 4 };
  const echo = { fullName: '回显参数', id: 5 };
  return props.hasPage ? [parameter, props.activeStep == 1 ? page : echo, ...list] : [parameter, ...list];
});
 
function onTableChange(item, index, key?) {
  if (key === 'source') item.defaultValue = '';
  props.list[index] = item;
}
function remove(index) {
  createConfirm({
    iconType: 'warning',
    title: $t('common.tipTitle'),
    content: '此操作删除该数据, 是否继续?',
    onOk: () => {
      props.list.splice(index, 1);
    },
  });
}
</script>
<template>
  <BasicVxeTable @register="registerTable" :data-source="list">
    <template #field="{ record, index }">
      <a-input v-model:value="record.field" placeholder="请输入" allow-clear @change="onTableChange(record, index)" />
    </template>
    <template #dataType="{ record, index }">
      <jnpf-select v-model:value="record.dataType" :options="typeList" placeholder="请选择" @change="onTableChange(record, index)" />
    </template>
    <template #source="{ record, index }">
      <jnpf-select v-model:value="record.source" :options="getSourceList" :disabled="sourceDisabled" @change="onTableChange(record, index, 'source')" />
    </template>
    <template #defaultValue="{ record, index }">
      <jnpf-select
        v-if="record.source === 1 || record.source == 4 || record.source == 5"
        v-model:value="record.defaultValue"
        :options="record.source === 1 ? parameterJson : record.source === 4 ? pageParameters : echoParameters"
        :field-names="{ label: 'field', value: 'field' }"
        allow-clear
        @change="onTableChange(record, index)" />
      <jnpf-tree-select
        v-else-if="record.source === 2"
        v-model:value="record.defaultValue"
        :options="fieldTreeData"
        placeholder="请选择"
        last-level
        allow-clear
        last-level-key="type"
        :last-level-value="1"
        @change="onTableChange(record, index)" />
      <a-input v-else-if="record.source === 3" v-model:value="record.defaultValue" placeholder="请输入" allow-clear @change="onTableChange(record, index)" />
    </template>
    <template #action="{ index }">
      <a-button class="action-btn" type="link" color="error" @click="remove(index)" size="small">删除</a-button>
    </template>
  </BasicVxeTable>
</template>