index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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('marketingApps.name')" prop="domain">
  7. <el-input :placeholder="t('marketingApps.inputNameTip')" clearable
  8. v-model="state.queryForm.domain" />
  9. </el-form-item>
  10. <el-form-item :label="'应用ID'" prop="appId">
  11. <el-input :placeholder="'请输入应用ID'" clearable v-model="state.queryForm.appId" />
  12. </el-form-item>
  13. <el-form-item :label="'应用类型'" prop="appType">
  14. <el-select placeholder="请选择应用类型" v-model="state.queryForm.appType">
  15. <el-option :key="''" :label="'全部'" :value="''" />
  16. <el-option v-for="item in appTypes" :key="item.value" :label="item.description" :value="item.value" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item :label="'备注'" prop="remark">
  20. <el-input :placeholder="'请输入备注'" clearable v-model="state.queryForm.domain" />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button @click="query" class="ml10" icon="search" type="primary">
  24. {{ t('common.queryBtn') }}
  25. </el-button>
  26. <el-button @click="resetQuery" icon="Refresh">{{ t('common.resetBtn') }}</el-button>
  27. <el-button @click="handleEdit" icon="EditPen" :disabled="activeName === 'tab2'">{{ t('common.editBtn') }}</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </el-row>
  31. <!-- <el-row>
  32. <div class="mb8" style="width: 100%">
  33. <right-toolbar v-model:showSearch="showSearch" class="ml10" style="float: right; margin-right: 20px"
  34. @queryTable="getDataList"></right-toolbar>
  35. </div>
  36. </el-row> -->
  37. <el-tabs v-model="activeName" class="table-tabs" @tab-click="handleClick">
  38. <el-tab-pane label="使用中" name="tab1"></el-tab-pane>
  39. <el-tab-pane label="回收站" name="tab2"></el-tab-pane>
  40. </el-tabs>
  41. <el-table @selection-change="handleSelectionChange" ref="tableRef" :data="state.dataList" row-key="path"
  42. style="width: 100%" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
  43. :header-cell-style="tableStyle?.headerCellStyle">
  44. <el-table-column type="selection" fixed="left" width="55" v-if="activeName == 'tab1'" />
  45. <el-table-column fixed="left" :label="t('marketingApps.id')" prop="id" width="80" show-overflow-tooltip>
  46. <template #default="{ row }">{{ row.id }}</template>
  47. </el-table-column>
  48. <el-table-column :label="t('marketingApps.appId')" prop="appId" width="120" show-overflow-tooltip>
  49. <template #default="{ row }">{{ row.appId }}</template>
  50. </el-table-column>
  51. <el-table-column :label="t('marketingApps.appImg')" prop="appImg" width="150" show-overflow-tooltip>
  52. <template #default="{ row }" style="display: flex; align-self: center;">
  53. <el-image style="width: 80px; height: 80px" :src="row.appImg" :fit="fit" />
  54. </template>
  55. </el-table-column>
  56. <el-table-column :label="t('marketingApps.name')" prop="appName" width="150" show-overflow-tooltip>
  57. <template #default="{ row }">
  58. <el-link :href="row.url">{{ row.appName }}</el-link>
  59. </template>
  60. </el-table-column>
  61. <el-table-column :label="t('marketingApps.appType')" prop="domainType" width="110" show-overflow-tooltip>
  62. <template #default="{ row }">
  63. <el-select :disabled="activeName === 'tab2'" v-model="row.domainType" placeholder="" style="width: 80px">
  64. <el-option v-for="item in appTypes" :key="item.value" :label="item.description" :value="item.value" />
  65. </el-select>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="营销投放" prop="launch" width="120">
  69. <template #default="{ row }">
  70. <el-switch :disabled="activeName === 'tab2'" v-model="row.launch" inline-prompt :active-value="true"
  71. :inactive-value="false" @change="handleChange(row)" />
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="域名限制" prop="domainLimit" width="120">
  75. <template #default="{ row }">
  76. <el-switch :disabled="activeName === 'tab2'" v-model="row.domainLimit" inline-prompt :active-value="true"
  77. :inactive-value="false" @change="handleChange(row)" />
  78. </template>
  79. </el-table-column>
  80. <el-table-column :label="'域名集合'" prop="domains" width="280" show-overflow-tooltip>
  81. <template #default="{ row }">
  82. <DomainCell :domainList="row.domains" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column :label="'IP集合'" prop="ips" width="320">
  86. <template #default="{ row }">
  87. <IpCell :ipList="row.ips" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column :label="'触发频率'" prop="triggerRule" width="150" show-overflow-tooltip>
  91. <template #default="{ row }">
  92. <!-- <el-input-number v-model="row.triggerNum" :max=20 /> -->
  93. {{ row.triggerNum }}
  94. </template>
  95. </el-table-column>
  96. <el-table-column :label="t('marketingApps.triggerRule')" width="140" prop="triggerRule" show-overflow-tooltip>
  97. <template #default="{ row }">
  98. <el-select :disabled="activeName === 'tab2'" v-model="row.triggerRule" placeholder="" style="width: 100px">
  99. <el-option v-for="item in triggerRules" :key="item.value" :label="item.label" :value="item.value" />
  100. </el-select>
  101. </template>
  102. </el-table-column>
  103. <el-table-column fixed="right" :label="t('common.action')" width="200">
  104. <template #default="scope">
  105. <div class="action" style="text-align: left;">
  106. <el-button :disabled="activeName == 'tab2'" style="margin-right: 0px;" @click="onOpenEditMenu('edit', scope.row)" text type="primary"
  107. v-auth="'sys_menu_edit'">
  108. <svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
  109. <mask id="mask0_362_1714" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="16" height="16">
  110. <rect width="16" height="16" fill="#D9D9D9"/>
  111. </mask>
  112. <g mask="url(#mask0_362_1714)">
  113. <path d="M4.60017 12.2954L5.97782 12.2954C6.50827 12.2955 7.017 12.0847 7.39208 11.7097L13.7925 5.30925C14.4017 4.70003 14.4017 3.71229 13.7925 3.10308V3.10308C13.1833 2.49386 12.1955 2.49387 11.5863 3.10308L5.18591 9.5035C4.81082 9.87859 4.60011 10.3873 4.60012 10.9178L4.60017 12.2954Z" stroke="#167AF0" stroke-linejoin="round"/>
  114. <path d="M10.4832 4.20593L12.6893 6.41211" stroke="#167AF0" stroke-linecap="round" stroke-linejoin="round"/>
  115. <path d="M8.5 2H4C2.89543 2 2 2.89543 2 4V13C2 14.1046 2.89543 15 4 15H13C14.1046 15 15 14.1046 15 13V8.5" stroke="#167AF0" stroke-linecap="round"/>
  116. </g>
  117. </svg>
  118. 修改</el-button>
  119. <el-button style="margin-right: 0px;" @click="onOpenStatistical(scope.row)" text type="primary"
  120. v-auth="'sys_menu_edit'">
  121. <svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
  122. <path d="M2 6V3C2 2.44772 2.44772 2 3 2H13C13.5523 2 14 2.44772 14 3V6" stroke="#167AF0" stroke-linecap="round" stroke-linejoin="round"/>
  123. <path d="M10.6667 8V10.3333" stroke="#167AF0" stroke-linecap="round" stroke-linejoin="round"/>
  124. <path d="M8 5V10.3333" stroke="#167AF0" stroke-linecap="round" stroke-linejoin="round"/>
  125. <path d="M5.33325 6.33334V10.3333" stroke="#167AF0" stroke-linecap="round" stroke-linejoin="round"/>
  126. <path d="M2 10V13C2 13.5523 2.44772 14 3 14H13C13.5523 14 14 13.5523 14 13V10" stroke="#167AF0" stroke-linecap="round" stroke-linejoin="round"/>
  127. </svg>
  128. 统计</el-button>
  129. <el-button v-if="activeName == 'tab1'" style="margin-right: 0px;" @click="handleDelete(scope.row)" text type="danger"
  130. v-auth="'sys_menu_edit'">
  131. <svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
  132. <g clip-path="url(#clip0_35_722)">
  133. <path d="M3 3.33334V12.6667C3 13.7712 3.89543 14.6667 5 14.6667H11C12.1046 14.6667 13 13.7712 13 12.6667V3.33334H3Z" stroke="#E64242" stroke-linejoin="round"/>
  134. <path d="M6.66675 6.66666V11" stroke="#E64242" stroke-linecap="round" stroke-linejoin="round"/>
  135. <path d="M9.33325 6.66666V11" stroke="#E64242" stroke-linecap="round" stroke-linejoin="round"/>
  136. <path d="M1.33325 3.33334H14.6666" stroke="#E64242" stroke-linecap="round" stroke-linejoin="round"/>
  137. <path d="M5.33325 3.33334L6.42959 1.33334H9.59229L10.6666 3.33334H5.33325Z" stroke="#E64242" stroke-linejoin="round"/>
  138. </g>
  139. <defs>
  140. <clipPath id="clip0_35_722">
  141. <rect width="16" height="16" fill="white"/>
  142. </clipPath>
  143. </defs>
  144. </svg>
  145. 拉黑</el-button>
  146. <el-button v-if="activeName == 'tab2'" style="margin-right: 0px;" icon="refresh" @click="handleDelete(scope.row)" text type="success"
  147. v-auth="'sys_menu_edit'">还原</el-button>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
  153. </div>
  154. <EditDialog @refresh="getDataList()" ref="EditDialogRef" />
  155. <StatisticalDialog @refresh="getDataList()" ref="statisticalDialogRef" />
  156. </div>
  157. </template>
  158. <script lang="ts" name="marketingApps" setup>
  159. import { pageList } from '/@/api/marketing/apps';
  160. import { BasicTableProps, useTable } from '/@/hooks/table';
  161. import { useMessage, useMessageBox } from '/@/hooks/message';
  162. import { useI18n } from 'vue-i18n';
  163. import { fetchItemList } from '/@/api/admin/dict';
  164. import { ref } from 'vue'
  165. const EditDialog = defineAsyncComponent(() => import('./components/form.vue'));
  166. const StatisticalDialog = defineAsyncComponent(() => import('./components/statistical.vue'));
  167. const IpCell = defineAsyncComponent(() => import('./components/ipCell.vue'));
  168. const DomainCell = defineAsyncComponent(() => import('./components/domainCell.vue'));
  169. import { ElMessage, type TabsPaneContext } from 'element-plus'
  170. const activeName = ref('tab1')
  171. const handleClick = (tab: TabsPaneContext, event: Event) => {
  172. console.log(tab, event);
  173. query();
  174. }
  175. const { t } = useI18n();
  176. // 定义变量内容
  177. const tableRef = ref();
  178. const EditDialogRef = ref();
  179. const statisticalDialogRef = ref();
  180. const queryRef = ref();
  181. const showSearch = ref(true);
  182. // 多选rows
  183. const selectObjs = ref([]) as any;
  184. // 是否可以多选
  185. const multiple = ref(true);
  186. const state: BasicTableProps = reactive<BasicTableProps>({
  187. pageList: pageList,
  188. queryForm: {
  189. domain: '',
  190. appType: '',
  191. appId: '',
  192. remark: '',
  193. }
  194. });
  195. const appTypes = ref([]) as any;
  196. const getAppTypes = async () => {
  197. const { data } = await fetchItemList({
  198. dictType: 'DomianType'
  199. });
  200. appTypes.value = data?.records || [];
  201. }
  202. getAppTypes();
  203. const triggerRules = [
  204. {
  205. label: '仅一次',
  206. value: 1,
  207. },
  208. {
  209. label: '多次',
  210. value: 2,
  211. },
  212. ]
  213. const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state);
  214. // 搜索事件
  215. const query = () => {
  216. state.dataList = [];
  217. getDataList();
  218. };
  219. // 修改单条配置信息
  220. const handleChange = (row: any) => {
  221. // update(row).then(() => {
  222. // useMessage().success(t('common.updateSuccessText'));
  223. // getDataList();
  224. // }).catch((err: any) => {
  225. // useMessage().error(err.msg);
  226. // });
  227. useMessage().success('修改成功');
  228. };
  229. // 清空搜索条件
  230. const resetQuery = () => {
  231. queryRef.value.resetFields();
  232. state.dataList = [];
  233. getDataList();
  234. };
  235. // 批量修改配置
  236. const handleEdit = () => {
  237. if (selectObjs.value.length === 0) {
  238. useMessage().warning('请选择要修改的项');
  239. return;
  240. }
  241. EditDialogRef.value.openDialog('', {});
  242. // EditDialogRef.value.openDialog('edit', selectObjs.value);
  243. };
  244. // 多选
  245. const handleSelectionChange = (selection: any) => {
  246. selectObjs.value = selection;
  247. };
  248. // 打开编辑菜单弹窗
  249. const onOpenEditMenu = (type: string, row: any) => {
  250. EditDialogRef.value.openDialog(type, row);
  251. };
  252. // 打开统计弹窗
  253. const onOpenStatistical = (row: any) => {
  254. statisticalDialogRef.value.openDialog(row);
  255. };
  256. // 删除操作
  257. const handleDelete = async (row: any) => {
  258. try {
  259. if(activeName.value == 'tab1'){
  260. await useMessageBox().confirm('是否确认拉黑该应用');
  261. }else{
  262. ElMessage.success('还原成功!');
  263. }
  264. } catch {
  265. return;
  266. }
  267. // try {
  268. // await delObj(ids);
  269. // getDataList();
  270. // useMessage().success(t('common.delSuccessText'));
  271. // } catch (err: any) {
  272. // useMessage().error(err.msg);
  273. // }
  274. query();
  275. };
  276. </script>
  277. <style scoped lang="scss">
  278. :deep(.el-link__inner) {
  279. display: inline-block;
  280. width: 100%;
  281. justify-content: start;
  282. }
  283. :deep(.el-link.is-underline:hover:after) {
  284. display: none;
  285. }
  286. .table-tabs {
  287. margin-bottom: 10px;
  288. }
  289. </style>