index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: flex; flex-wrap: wrap; margin-left: 14%;">
  49. <div
  50. style="display: flex; margin-right: 30px; text-align: left; float: left; justify-content: start; line-height: 25px;"
  51. v-for="item in scope.row.configs" :key="item.ip">
  52. <!-- <el-tag class="mr10">{{ item.ip }}</el-tag>: -->
  53. <span :title="item.ip" style="display: inline-block;">{{ item.ip }}</span>:
  54. <el-link :title="item.appName" style="color: var(--el-color-primary); text-align: left;" :href="item.download">{{ item.appName }}</el-link>
  55. </div>
  56. </div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column :label="$t('common.action')" show-overflow-tooltip width="250">
  60. <template #default="scope">
  61. <el-button icon="edit-pen" @click="onOpenEditMenu('edit', scope.row)" text type="primary" v-auth="'sys_menu_edit'"
  62. >{{ $t('common.editBtn') }}
  63. </el-button>
  64. <span style="margin-left: 12px">
  65. <el-button
  66. icon="delete"
  67. @click="handleDelete([scope.row.id])"
  68. text
  69. type="primary"
  70. v-auth="'sys_menu_del'"
  71. >
  72. {{ $t('common.delBtn') }}
  73. </el-button>
  74. </span>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </div>
  79. <MenuDialog @refresh="getDataList()" ref="menuDialogRef" />
  80. </div>
  81. </template>
  82. <script lang="ts" name="marketingConfig" setup>
  83. import { delObj, pageList } from '/@/api/marketing/config';
  84. import { BasicTableProps, useTable } from '/@/hooks/table';
  85. import { useMessage, useMessageBox } from '/@/hooks/message';
  86. import { useI18n } from 'vue-i18n';
  87. // 引入组件
  88. const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
  89. const { t } = useI18n();
  90. // 定义变量内容
  91. const tableRef = ref();
  92. const menuDialogRef = ref();
  93. const queryRef = ref();
  94. const showSearch = ref(true);
  95. // 多选rows
  96. const selectObjs = ref([]) as any;
  97. // 是否可以多选
  98. const multiple = ref(true);
  99. const state: BasicTableProps = reactive<BasicTableProps>({
  100. pageList: pageList, // H
  101. queryForm: {
  102. domain: '',
  103. }
  104. });
  105. const { getDataList, tableStyle } = useTable(state);
  106. // 打开新增菜单弹窗
  107. const onOpenAddMenu = (type?: string, row?: any) => {
  108. menuDialogRef.value.openDialog(type, row);
  109. };
  110. // 打开编辑菜单弹窗
  111. const onOpenEditMenu = (type: string, row: any) => {
  112. menuDialogRef.value.openDialog(type, row);
  113. };
  114. // 搜索事件
  115. const query = () => {
  116. state.dataList = [];
  117. getDataList();
  118. };
  119. // 清空搜索条件
  120. const resetQuery = () => {
  121. queryRef.value.resetFields();
  122. state.dataList = [];
  123. getDataList();
  124. };
  125. // 多选事件
  126. const handleSelectionChange = (objs: { id: string }[]) => {
  127. selectObjs.value = objs.map(({ id }) => id);
  128. multiple.value = !objs.length;
  129. };
  130. // 删除操作
  131. const handleDelete = async (ids: string[]) => {
  132. try {
  133. await useMessageBox().confirm(t('common.delConfirmText'));
  134. } catch {
  135. return;
  136. }
  137. try {
  138. await delObj(ids);
  139. getDataList();
  140. useMessage().success(t('common.delSuccessText'));
  141. } catch (err: any) {
  142. useMessage().error(err.msg);
  143. }
  144. };
  145. </script>
  146. <style scoped>
  147. :deep(.el-link__inner) {
  148. display: inline-block;
  149. width: 100%;
  150. justify-content: start;
  151. }
  152. </style>