index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div class="setting-box">
  3. <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false">
  4. <template #bodyCell="{ column, record }">
  5. <template v-if="column.dataIndex === 'operation'">
  6. <a class="action-link" @click="handleEdit(record)">编辑</a>
  7. </template>
  8. <template v-if="column.dataIndex === 'logoIcon' || column.dataIndex === 'loginBack'">
  9. <span>{{ record[column.dataIndex] }}</span>
  10. <img width="50" height="50" :src="urlStr + '/sys/common/static/' + record[column.dataIndex]" />
  11. </template>
  12. </template>
  13. </a-table>
  14. <DetailModal @register="register" @success="getDataSource" />
  15. </div>
  16. </template>
  17. <script lang="ts" name="system-setting" setup>
  18. import { ref, onMounted } from 'vue';
  19. import { useModal } from '/@/components/Modal';
  20. import DetailModal from './DetailModal.vue';
  21. import { columns } from './setting.data';
  22. import { getList } from './setting.api';
  23. import { useGlobSetting } from '/@/hooks/setting';
  24. const globSetting = useGlobSetting();
  25. const baseUploadUrl = globSetting.uploadUrl;
  26. let urlStr = '';
  27. if (import.meta.env.PROD) {
  28. urlStr = VUE_APP_URL.baseUrl;
  29. } else {
  30. urlStr = baseUploadUrl || '';
  31. }
  32. const [register, { openModal: openDetail }] = useModal();
  33. const dataSource = ref<any[]>([]);
  34. async function getDataSource() {
  35. const result = await getList({});
  36. dataSource.value = [result];
  37. }
  38. /**
  39. * 编辑事件
  40. */
  41. function handleEdit(record) {
  42. openDetail(true, {
  43. record,
  44. isUpdate: true,
  45. });
  46. }
  47. onMounted(async () => {
  48. await getDataSource();
  49. });
  50. </script>
  51. <style lang="less" scoped>
  52. .setting-box {
  53. margin: 10px 8px;
  54. height: calc(100% - 72px);
  55. padding-bottom: 10px;
  56. border: 1px solid #44d3ff70;
  57. border-radius: 2px;
  58. box-shadow: 0 0 20px #44b4ff33 inset;
  59. background-color: #ffffff11;
  60. overflow-y: auto;
  61. }
  62. </style>