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
<script lang="ts" setup>
import { computed, reactive, ref } from 'vue';
 
import { BasicPopup, usePopupInner } from '@jnpf/ui/popup';
import { BasicVxeTable, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { getDataModelFieldList, previewDataModel } from '#/api/systemData/dataModel';
import { $t } from '#/locales';
 
defineEmits(['register']);
 
const [registerPopup] = usePopupInner(init);
const columns = ref([]);
const searchInfo = reactive({
  linkId: '',
  table: '',
});
 
const getTitle = computed(() => `${searchInfo.table}表的数据`);
const [registerTable, { getForm }] = useVxeTable({
  api: previewDataModel,
  searchInfo,
  useSearchForm: true,
  formConfig: {
    baseColProps: { span: 8 },
    schemas: [
      {
        field: 'field',
        label: '字段',
        component: 'Select',
        defaultValue: '',
        componentProps: { placeholder: '请选择', allowClear: false, showSearch: true, fieldNames: { value: 'field', label: 'field' } },
      },
      {
        field: 'keyword',
        label: $t('common.keyword'),
        component: 'Input',
        componentProps: {
          placeholder: $t('common.enterKeyword'),
          submitOnPressEnter: true,
        },
      },
    ],
  },
  immediate: false,
});
function init(data) {
  searchInfo.linkId = data.linkId;
  searchInfo.table = data.table;
  getOptions(data);
}
async function getOptions({ linkId, table }) {
  const res = await getDataModelFieldList(linkId, table);
  columns.value = res.data.list.map((o) => ({
    ...o,
    title: o.field,
    dataIndex: o.field.toLowerCase(),
    slots: { default: 'custom' },
  }));
  getForm().updateSchema({ field: 'field', componentProps: { options: res.data.list }, defaultValue: res.data.list[0].field });
  getForm().setFieldsValue({ field: res.data.list[0].field });
  getForm().submit();
}
</script>
<template>
  <BasicPopup v-bind="$attrs" @register="registerPopup" :title="getTitle" class="full-popup">
    <BasicVxeTable :columns="columns" @register="registerTable" class="jnpf-sub-table">
      <template #custom="{ record, column }">
        <p>{{ record[column.field.toLowerCase()] }}</p>
      </template>
    </BasicVxeTable>
  </BasicPopup>
</template>