index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="layout-padding">
  3. <div class="layout-padding-auto layout-padding-view">
  4. <el-row shadow="hover" v-show="showSearch" class="ml10">
  5. <el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
  6. <el-form-item :label="$t('marketingConfig.name')" prop="domain">
  7. <el-input :placeholder="$t('marketingConfig.inputNameTip')" clearable style="max-width: 180px" v-model="state.queryForm.domain" />
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button @click="query" class="ml10" icon="search" type="primary">
  11. {{ $t('common.queryBtn') }}
  12. </el-button>
  13. <el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
  14. </el-form-item>
  15. </el-form>
  16. </el-row>
  17. <el-row>
  18. <div class="mb8" style="width: 100%">
  19. <el-button @click="onOpenAddMenu" class="ml10" icon="folder-add" type="primary" v-auth="'sys_menu_add'">
  20. {{ $t('common.addBtn') }}
  21. </el-button>
  22. <el-button plain :disabled="multiple" icon="Delete" type="primary" class="ml10" v-auth="'sys_user_del'" @click="handleDelete(selectObjs)">
  23. {{ $t('common.delBtn') }}
  24. </el-button>
  25. <right-toolbar
  26. v-model:showSearch="showSearch"
  27. class="ml10"
  28. style="float: right; margin-right: 20px"
  29. @queryTable="getDataList"
  30. ></right-toolbar>
  31. </div>
  32. </el-row>
  33. <el-table
  34. ref="tableRef"
  35. :data="state.dataList"
  36. row-key="path"
  37. style="width: 100%"
  38. v-loading="state.loading"
  39. border
  40. :cell-style="tableStyle.cellStyle"
  41. :header-cell-style="tableStyle?.headerCellStyle"
  42. @selection-change="handleSelectionChange"
  43. >
  44. <el-table-column type="selection" :selectable="handleSelectable" width="50" align="center" />
  45. <el-table-column :label="$t('marketingConfig.name')" fixed prop="domain" width="240" show-overflow-tooltip></el-table-column>
  46. <el-table-column :label="$t('marketingConfig.config')" prop="configs">
  47. <template #default="scope">
  48. <div style="display: inline-block; margin-right: 10px;width: 22%; text-align: left; float: left;" v-for="item in scope.row.configs" :key="item.ip">
  49. <!-- <el-tag class="mr10">{{ item.ip }}</el-tag>: -->
  50. <span style="display: inline-block;">{{ item.ip }}</span>:<el-link style="color: var(--el-color-primary);" :href="item.download">{{ item.appName }}</el-link>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column :label="$t('common.action')" show-overflow-tooltip width="250">
  55. <template #default="scope">
  56. <el-button icon="edit-pen" @click="onOpenEditMenu('edit', scope.row)" text type="primary" v-auth="'sys_menu_edit'"
  57. >{{ $t('common.editBtn') }}
  58. </el-button>
  59. <span style="margin-left: 12px">
  60. <el-button
  61. icon="delete"
  62. @click="handleDelete([scope.row.id])"
  63. text
  64. type="primary"
  65. v-auth="'sys_menu_del'"
  66. >
  67. {{ $t('common.delBtn') }}
  68. </el-button>
  69. </span>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. </div>
  74. <MenuDialog @refresh="getDataList()" ref="menuDialogRef" />
  75. </div>
  76. </template>
  77. <script lang="ts" name="marketingConfig" setup>
  78. import { delObj, pageList } from '/@/api/marketing/config';
  79. import { BasicTableProps, useTable } from '/@/hooks/table';
  80. import { useMessage, useMessageBox } from '/@/hooks/message';
  81. import { useI18n } from 'vue-i18n';
  82. // 引入组件
  83. const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
  84. const { t } = useI18n();
  85. // 定义变量内容
  86. const tableRef = ref();
  87. const menuDialogRef = ref();
  88. const queryRef = ref();
  89. const showSearch = ref(true);
  90. // 多选rows
  91. const selectObjs = ref([]) as any;
  92. // 是否可以多选
  93. const multiple = ref(true);
  94. const state: BasicTableProps = reactive<BasicTableProps>({
  95. pageList: pageList, // H
  96. queryForm: {
  97. domain: '',
  98. }
  99. });
  100. const { getDataList, tableStyle } = useTable(state);
  101. // 打开新增菜单弹窗
  102. const onOpenAddMenu = (type?: string, row?: any) => {
  103. menuDialogRef.value.openDialog(type, row);
  104. };
  105. // 打开编辑菜单弹窗
  106. const onOpenEditMenu = (type: string, row: any) => {
  107. menuDialogRef.value.openDialog(type, row);
  108. };
  109. // 搜索事件
  110. const query = () => {
  111. state.dataList = [];
  112. getDataList();
  113. };
  114. // 清空搜索条件
  115. const resetQuery = () => {
  116. queryRef.value.resetFields();
  117. state.dataList = [];
  118. getDataList();
  119. };
  120. // 多选事件
  121. const handleSelectionChange = (objs: { id: string }[]) => {
  122. selectObjs.value = objs.map(({ id }) => id);
  123. multiple.value = !objs.length;
  124. };
  125. // 删除操作
  126. const handleDelete = async (ids: string[]) => {
  127. try {
  128. await useMessageBox().confirm(t('common.delConfirmText'));
  129. } catch {
  130. return;
  131. }
  132. try {
  133. await delObj(ids);
  134. getDataList();
  135. useMessage().success(t('common.delSuccessText'));
  136. } catch (err: any) {
  137. useMessage().error(err.msg);
  138. }
  139. };
  140. </script>