SmartAuthSecretKeyListView.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="full-height page-container">
  3. <LayoutSeparate first-size="240px" :show-line="false" class="full-height">
  4. <template #first>
  5. <div class="full-height system-container">
  6. <SystemSimpleList
  7. @current-change="handleSelectSystemChange"
  8. :row-config="{ isHover: true, isCurrent: true }"
  9. height="auto"
  10. />
  11. </div>
  12. </template>
  13. <template #second>
  14. <SmartTable @register="registerTable" :size="getTableSize">
  15. <template #table-operation="{ row }">
  16. <SmartVxeTableAction :actions="getActions(row)" />
  17. </template>
  18. <template #form-publicKeyFile="{ model }">
  19. <Upload
  20. v-model:fileList="model.publicKeyFileList"
  21. accept=".keystore"
  22. :max-count="1"
  23. :beforeUpload="() => false"
  24. >
  25. <a-button>Upload</a-button>
  26. </Upload>
  27. </template>
  28. <template #form-privateKeyFile="{ model }">
  29. <Upload
  30. v-model:fileList="model.privateKeyFileList"
  31. accept=".keystore"
  32. :max-count="1"
  33. :beforeUpload="() => false"
  34. >
  35. <a-button>Upload</a-button>
  36. </Upload>
  37. </template>
  38. </SmartTable>
  39. </template>
  40. </LayoutSeparate>
  41. </div>
  42. </template>
  43. <script lang="ts" setup>
  44. import { ref, unref } from 'vue';
  45. import { useI18n } from '@/hooks/web/useI18n';
  46. import { useSizeSetting } from '@/hooks/setting/UseSizeSetting';
  47. import { Upload } from 'ant-design-vue';
  48. import {
  49. ActionItem,
  50. SmartTable,
  51. SmartVxeTableAction,
  52. useSmartTable,
  53. } from '@/components/SmartTable';
  54. import LayoutSeparate from '@/components/LayoutSeparate/src/LayoutSeparate';
  55. import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue';
  56. import { hasPermission } from '@/utils/auth';
  57. import {
  58. getTableColumns,
  59. getFormSchemas,
  60. getSearchFormSchemas,
  61. } from './SmartAuthSecretKeyListView.config';
  62. import {
  63. listApi,
  64. deleteApi,
  65. getByIdApi,
  66. saveUpdateApi,
  67. download,
  68. } from './SmartAuthSecretKeyListView.api';
  69. const { t } = useI18n();
  70. const { getTableSize } = useSizeSetting();
  71. /**
  72. * 系统变更时触发:更新数据
  73. */
  74. const currentSystemRef = ref<Recordable>({});
  75. const handleSelectSystemChange = (system) => {
  76. currentSystemRef.value = system;
  77. query();
  78. };
  79. const getActions = (row: Recordable): ActionItem[] => {
  80. return [
  81. {
  82. label: t('common.button.edit'),
  83. auth: 'auth:secret:update',
  84. onClick: () => {
  85. editByRowModal(row);
  86. },
  87. },
  88. {
  89. label: t('common.button.download'),
  90. auth: 'auth:secret:download',
  91. onClick: () => {
  92. download(row.id);
  93. },
  94. },
  95. ];
  96. };
  97. const [registerTable, { editByRowModal, query }] = useSmartTable({
  98. columns: getTableColumns(),
  99. height: 'auto',
  100. pagerConfig: true,
  101. useSearchForm: true,
  102. stripe: true,
  103. highlightHoverRow: true,
  104. columnConfig: {
  105. resizable: true,
  106. },
  107. border: true,
  108. authConfig: {
  109. authHandler: hasPermission,
  110. toolbar: {
  111. ModalAdd: 'auth:secret:save',
  112. delete: 'auth:secret:delete',
  113. },
  114. },
  115. sortConfig: {
  116. remote: true,
  117. defaultSort: {
  118. field: 'seq',
  119. order: 'asc',
  120. },
  121. },
  122. searchFormConfig: {
  123. schemas: getSearchFormSchemas(t),
  124. searchWithSymbol: true,
  125. colon: true,
  126. layout: 'inline',
  127. actionColOptions: {
  128. span: undefined,
  129. },
  130. compact: true,
  131. },
  132. addEditConfig: {
  133. formConfig: {
  134. schemas: getFormSchemas(t),
  135. baseColProps: { span: 24 },
  136. labelCol: { span: 6 },
  137. wrapperCol: { span: 17 },
  138. colon: true,
  139. },
  140. },
  141. proxyConfig: {
  142. ajax: {
  143. query: (params) => {
  144. const parameter = {
  145. ...params.ajaxParameter,
  146. systemId: unref(currentSystemRef)?.id,
  147. };
  148. return listApi(parameter);
  149. },
  150. save: ({ body: { insertRecords, updateRecords } }) => {
  151. const dataList = [...insertRecords, ...updateRecords];
  152. return saveUpdateApi({
  153. ...dataList[0],
  154. systemId: unref(currentSystemRef).id,
  155. });
  156. },
  157. delete: ({ body: { removeRecords } }) => deleteApi(removeRecords),
  158. getById: (params) => getByIdApi(params.id),
  159. },
  160. },
  161. importConfig: {},
  162. exportConfig: {},
  163. toolbarConfig: {
  164. zoom: true,
  165. refresh: true,
  166. column: {
  167. columnOrder: true,
  168. },
  169. buttons: [
  170. {
  171. code: 'ModalAdd',
  172. },
  173. {
  174. code: 'delete',
  175. },
  176. ],
  177. },
  178. });
  179. </script>
  180. <style lang="less" scoped>
  181. .system-container {
  182. margin-right: 5px;
  183. background: white;
  184. }
  185. </style>