tpl.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div>
  3. <BasicTable @register="registerTable">
  4. <template #toolbar>
  5. <a-button type="default" @click="handleImport()">
  6. <Icon icon="i-ant-design:import-outlined" /> {{ '导入' }}
  7. </a-button>
  8. <a-button type="primary" @click="handleForm({ op: 'add' })" v-auth="'sys:empUser:edit'">
  9. <Icon icon="i-fluent:add-12-filled" /> {{ '新增' }}
  10. </a-button>
  11. </template>
  12. </BasicTable>
  13. </div>
  14. </template>
  15. <script lang="ts" setup name="ViewsCaseDataTemplateList">
  16. import { ref, onMounted } from 'vue';
  17. import { Icon } from '@jeesite/core/components/Icon';
  18. import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
  19. import { TableInfo } from '../../api/tpl/types/dto';
  20. import { FormProps } from '@jeesite/core/components/Form';
  21. import { tplPage } from '@jeesite/plat/api/tpl/tplApi';
  22. const loading = ref(false);
  23. const searchForm: FormProps<TableInfo> = {
  24. baseColProps: { md: 8, lg: 6 },
  25. labelWidth: 100,
  26. showAdvancedButton: true,
  27. schemas: [
  28. {
  29. label: '模板名称',
  30. field: 'tableNameCn',
  31. component: 'Input',
  32. },
  33. {
  34. label: '表类别',
  35. field: 'classify',
  36. component: 'Select',
  37. componentProps: {
  38. options: [
  39. { label: '话单数据库', value: '话单数据库' },
  40. { label: '金融数据库', value: '金融数据库' },
  41. { label: '基本信息数据库', value: '基本信息数据库' },
  42. { label: '轨迹数据库', value: '轨迹数据库' },
  43. ],
  44. allowClear: true,
  45. onChange: handleSuccess,
  46. },
  47. },
  48. ],
  49. resetFunc: async () => {},
  50. };
  51. const ctrlPermi = ref('');
  52. const tableColumns: BasicColumn<TableInfo>[] = [
  53. { title: '表类别', dataIndex: 'classify', key: 'a.classify', width: 100 },
  54. { title: '表中文名称', dataIndex: 'tableNameCn', key: 'a.tableNameCn', width: 150 },
  55. { title: '检测表头', dataIndex: 'headers', key: 'a.headers' },
  56. ];
  57. const actionColumn: BasicColumn<TableInfo> = {
  58. width: 180,
  59. actions: (record: TableInfo) => [
  60. {
  61. icon: 'i-clarity:note-edit-line',
  62. title: '编辑模板',
  63. onClick: handleForm.bind(this, { id: record.id, op: 'edit' }),
  64. },
  65. {
  66. icon: 'i-ant-design:delete-outlined',
  67. color: 'error',
  68. title: '删除模板',
  69. popConfirm: {
  70. title: '是否确认删除模板',
  71. confirm: handleDelete.bind(this, { id: record.id }),
  72. },
  73. },
  74. ],
  75. dropDownActions: () => [],
  76. };
  77. const [registerTable, { reload, getForm }] = useTable<TableInfo>({
  78. api: tplPage,
  79. beforeFetch: (params) => {
  80. params.ctrlPermi = ctrlPermi.value;
  81. return params;
  82. },
  83. immediate: false,
  84. columns: tableColumns,
  85. actionColumn: actionColumn,
  86. formConfig: searchForm,
  87. showTableSetting: true,
  88. useSearchForm: true,
  89. showSearchForm: true,
  90. canResize: true,
  91. // pagination: { defaultPageSize: 10 },
  92. // defaultRowSelection: {
  93. // onChange: (selectedRowKeys: string[], _selectedRows: Recordable[]) => {
  94. // selectedRowKeysRef.value = selectedRowKeys;
  95. // },
  96. // },
  97. });
  98. onMounted(async () => {
  99. await reload();
  100. });
  101. async function handleImport() {
  102. loading.value = true;
  103. try {
  104. const params = getForm();
  105. loading.value = false;
  106. } catch (error) {
  107. loading.value = false;
  108. }
  109. }
  110. async function handleForm(record: Recordable) {
  111. loading.value = true;
  112. try {
  113. const params = getForm();
  114. loading.value = false;
  115. } catch (error) {
  116. loading.value = false;
  117. }
  118. }
  119. async function handleRule(record: Recordable) {}
  120. async function handleDelete(record: Recordable) {
  121. handleSuccess(record);
  122. }
  123. function handleSuccess(_record: Recordable) {
  124. reload();
  125. }
  126. </script>