diff --git a/config/unplugin/auto-import.ts b/config/unplugin/auto-import.ts index 69e7b9a..6d2de4c 100644 --- a/config/unplugin/auto-import.ts +++ b/config/unplugin/auto-import.ts @@ -21,7 +21,7 @@ export function configAutoImport() { '@vueuse/core', { dayjs: [['default', 'dayjs']], - 'lodash-es': ['cloneDeep', 'omit', 'pick', 'union', 'uniq', 'isNumber', 'uniqBy', 'isEmpty'], + 'lodash-es': ['cloneDeep', 'omit', 'pick', 'union', 'uniq', 'isNumber', 'uniqBy', 'isEmpty', 'merge'], '@/hooks': ['useModal'], }, ], diff --git a/src/api/all/propertyMarketing.ts b/src/api/all/propertyMarketing.ts index 063d2ce..67d610e 100644 --- a/src/api/all/propertyMarketing.ts +++ b/src/api/all/propertyMarketing.ts @@ -294,7 +294,7 @@ export const getPlacementAccountProjectsTrend = (params = {}) => { export const getPlacementGuide = (params: {}) => { return Http.get(`/v1/placement-account-projects/getGuideList`, params); }; -//查询投放指南历史 +// 查询投放指南历史 export const getPlacementGuideHistory = (params: {}) => { return Http.get(`/v1/placement-account-projects/getGuideListHistory`, params); }; @@ -312,7 +312,7 @@ export const getPlacementGuideDetail = (id: string) => { return Http.get(`/v1/placement-account-projects/historylog/${id}`); }; -//删除记录 +// 删除记录 export const deleteHistorylog = (id: string) => { return Http.delete(`/v1/placement-account-projects/historylog/${id}`); }; @@ -332,4 +332,12 @@ export const postPlacementAccountsSync = (id: string) => { return Http.post(`/v1/placement-accounts/${id}/sync-data`); }; +// 投放账号-子账号分页 +export const postSubAccount = (params = {}) => { + return Http.post('/v1/placement-accounts/get-subaccount', params); +}; +// 投放账号-添加子账号 +export const postAddSubAccount = (params = {}) => { + return Http.post('/v1/placement-accounts/subaccount', params); +}; diff --git a/src/hooks/useTableSelectionWithPagination.ts b/src/hooks/useTableSelectionWithPagination.ts new file mode 100644 index 0000000..ac13d17 --- /dev/null +++ b/src/hooks/useTableSelectionWithPagination.ts @@ -0,0 +1,87 @@ +import { ref, computed } from 'vue'; + +interface UseTableSelectionWithPaginationOptions { + rowKey?: string; // 主键字段名,默认 'id' + pageInfo?: { + page?: number; + page_size?: number; + total?: number; + }; + onPageChange?: (page: number) => void; + onPageSizeChange?: (size: number) => void; +} + +const DEFAULT_PAGE_INFO = { + page: 1, + page_size: 20, + total: 0, +}; + +export function useTableSelectionWithPagination(options: UseTableSelectionWithPaginationOptions = {}) { + const rowKey = options.rowKey || 'id'; + + const selectedRowKeys = ref>([]); + const selectedRows = ref([]); + + const pageInfo = ref(merge({}, DEFAULT_PAGE_INFO, options.pageInfo)); + + const dataSource = ref([]); + + // 单行选择 + const handleSelect = (selectedKeys: (string | number)[], rowKeyValue: string | number, record: any) => { + const select = selectedKeys.includes(rowKeyValue); + selectedRowKeys.value = selectedKeys; + + if (select) { + if (!selectedRows.value.some((v) => v[rowKey] === record[rowKey])) { + selectedRows.value.push(record); + } + } else { + selectedRows.value = selectedRows.value.filter((v) => v[rowKey] !== record[rowKey]); + } + }; + + // 全选/取消全选 + const handleSelectAll = (checked: boolean) => { + const currentPageRows = dataSource.value; + const currentPageKeys = currentPageRows.map((v) => v[rowKey]); + + if (checked) { + selectedRowKeys.value = Array.from(new Set([...selectedRowKeys.value, ...currentPageKeys])); + const allRows = [...selectedRows.value, ...currentPageRows]; + const map = new Map(); + allRows.forEach((row) => map.set(row[rowKey], row)); + selectedRows.value = Array.from(map.values()); + } else { + selectedRowKeys.value = selectedRowKeys.value.filter((key) => !currentPageKeys.includes(key)); + selectedRows.value = selectedRows.value.filter((row) => !currentPageKeys.includes(row[rowKey])); + } + }; + + const onPageChange = (page: number) => { + pageInfo.value.page = page; + options.onPageChange?.(page); + }; + const onPageSizeChange = (size: number) => { + pageInfo.value.page_size = size; + pageInfo.value.page = 1; + options.onPageSizeChange?.(size); + }; + + const rowSelection = computed(() => ({ + type: 'checkbox', + showCheckedAll: true, + })); + + return { + selectedRowKeys, + selectedRows, + dataSource, + pageInfo, + onPageChange, + onPageSizeChange, + rowSelection, + handleSelect, + handleSelectAll, + }; +} diff --git a/src/styles/components/date-picker.scss b/src/styles/components/date-picker.scss new file mode 100644 index 0000000..6120784 --- /dev/null +++ b/src/styles/components/date-picker.scss @@ -0,0 +1,15 @@ +.arco-picker { + border-radius: 4px !important; + border-color: #d7d7d9 !important; + background-color: #fff !important; + &:hover { + background-color: #fff !important; + } + &:focus-within, + &.arco-input-focus, + &.arco-textarea-focus { + background-color: var(--color-bg-2) !important; + border-color: rgb(var(--primary-6)) !important; + box-shadow: 0 0 0 0 var(--color-primary-light-2) !important; + } +} diff --git a/src/styles/components/index.scss b/src/styles/components/index.scss index 39ccb7a..00e6c0f 100644 --- a/src/styles/components/index.scss +++ b/src/styles/components/index.scss @@ -3,4 +3,7 @@ @import './checkbox.scss'; @import './pagination.scss'; @import './tabs.scss'; -@import './modal.scss'; \ No newline at end of file +@import './modal.scss'; +@import "./textarea.scss"; +@import "./select.scss"; +@import "./date-picker.scss" \ No newline at end of file diff --git a/src/styles/components/input.scss b/src/styles/components/input.scss index a352fa3..896bb8b 100644 --- a/src/styles/components/input.scss +++ b/src/styles/components/input.scss @@ -1,5 +1,15 @@ .arco-input-wrapper { - border-radius: 4px; - border-color: #d7d7d9; - background-color: #fff; + border-radius: 4px !important; + border-color: #d7d7d9 !important; + background-color: #fff !important; + &:hover { + background-color: #fff !important; + } + &:focus-within, + &.arco-input-focus, + &.arco-textarea-focus { + background-color: var(--color-bg-2) !important; + border-color: rgb(var(--primary-6)) !important; + box-shadow: 0 0 0 0 var(--color-primary-light-2) !important; + } } diff --git a/src/styles/components/modal.scss b/src/styles/components/modal.scss index aee1303..c088215 100644 --- a/src/styles/components/modal.scss +++ b/src/styles/components/modal.scss @@ -4,6 +4,11 @@ height: 56px; padding: 0 20px; .arco-modal-title { + font-family: $font-family-medium; + color: #211f24; + font-size: 16px; + font-style: normal; + font-weight: 400; justify-content: flex-start; } } diff --git a/src/styles/components/select.scss b/src/styles/components/select.scss new file mode 100644 index 0000000..cf0b8aa --- /dev/null +++ b/src/styles/components/select.scss @@ -0,0 +1,15 @@ +.arco-select { + border-radius: 4px !important; + border-color: #d7d7d9 !important; + background-color: #fff !important; + &:hover { + background-color: #fff !important; + } + &:focus-within, + &.arco-input-focus, + &.arco-textarea-focus { + background-color: var(--color-bg-2) !important; + border-color: rgb(var(--primary-6)) !important; + box-shadow: 0 0 0 0 var(--color-primary-light-2) !important; + } +} diff --git a/src/styles/components/textarea.scss b/src/styles/components/textarea.scss new file mode 100644 index 0000000..f87db35 --- /dev/null +++ b/src/styles/components/textarea.scss @@ -0,0 +1,15 @@ +.arco-textarea-wrapper { + border-radius: 4px !important; + border-color: #d7d7d9 !important; + background-color: #fff !important; + &:hover { + background-color: #fff !important; + } + &:focus-within, + &.arco-input-focus, + &.arco-textarea-focus { + background-color: var(--color-bg-2) !important; + border-color: rgb(var(--primary-6)) !important; + box-shadow: 0 0 0 0 var(--color-primary-light-2) !important; + } +} diff --git a/src/views/property-marketing/component.scss b/src/views/property-marketing/component.scss index f952093..e90c356 100644 --- a/src/views/property-marketing/component.scss +++ b/src/views/property-marketing/component.scss @@ -1,19 +1,3 @@ -.arco-input-wrapper, -.arco-select-view-single, -.arco-textarea-wrapper, -.arco-picker, -.arco-select-view-multiple { - border-radius: 4px; - border-color: #d7d7d9; - background-color: #fff; - &:focus-within, - &.arco-input-focus, - &.arco-textarea-focus { - background-color: var(--color-bg-2); - border-color: rgb(var(--primary-6)); - box-shadow: 0 0 0 0 var(--color-primary-light-2); - } -} .arco-modal { .cancel-btn { border-radius: 4px; diff --git a/src/views/property-marketing/media-account/account-dashboard/components/filter-block/style.scss b/src/views/property-marketing/media-account/account-dashboard/components/filter-block/style.scss index 7814361..48e2115 100644 --- a/src/views/property-marketing/media-account/account-dashboard/components/filter-block/style.scss +++ b/src/views/property-marketing/media-account/account-dashboard/components/filter-block/style.scss @@ -1,17 +1,4 @@ .container { - :deep(.arco-input-wrapper), - :deep(.arco-select-view-single), - :deep(.arco-select-view-multiple) { - border-radius: 4px; - border-color: #d7d7d9; - background-color: #fff; - &:focus-within, - &.arco-input-focus { - background-color: var(--color-bg-2); - border-color: rgb(var(--primary-6)); - box-shadow: 0 0 0 0 var(--color-primary-light-2); - } - } .filter-row { .filter-row-item { &:not(:last-child) { diff --git a/src/views/property-marketing/media-account/account-detail/components/note-table/style.scss b/src/views/property-marketing/media-account/account-detail/components/note-table/style.scss index 782fab8..e772b23 100644 --- a/src/views/property-marketing/media-account/account-detail/components/note-table/style.scss +++ b/src/views/property-marketing/media-account/account-detail/components/note-table/style.scss @@ -1,18 +1,4 @@ .note-table-wrap { - :deep(.arco-input-wrapper), - :deep(.arco-select-view-single), - :deep(.arco-select-view-multiple), - :deep(.arco-picker) { - border-radius: 4px; - border-color: #d7d7d9; - background-color: #fff; - &:focus-within, - &.arco-input-focus { - background-color: var(--color-bg-2); - border-color: rgb(var(--primary-6)); - box-shadow: 0 0 0 0 var(--color-primary-light-2); - } - } .filter-row { .filter-row-item { &:not(:last-child) { diff --git a/src/views/property-marketing/media-account/account-manage/components/filter-block/style.scss b/src/views/property-marketing/media-account/account-manage/components/filter-block/style.scss index 7814361..48e2115 100644 --- a/src/views/property-marketing/media-account/account-manage/components/filter-block/style.scss +++ b/src/views/property-marketing/media-account/account-manage/components/filter-block/style.scss @@ -1,17 +1,4 @@ .container { - :deep(.arco-input-wrapper), - :deep(.arco-select-view-single), - :deep(.arco-select-view-multiple) { - border-radius: 4px; - border-color: #d7d7d9; - background-color: #fff; - &:focus-within, - &.arco-input-focus { - background-color: var(--color-bg-2); - border-color: rgb(var(--primary-6)); - box-shadow: 0 0 0 0 var(--color-primary-light-2); - } - } .filter-row { .filter-row-item { &:not(:last-child) { diff --git a/src/views/property-marketing/media-account/components/group-select/index.vue b/src/views/property-marketing/media-account/components/group-select/index.vue index a441bfb..f72d0e3 100644 --- a/src/views/property-marketing/media-account/components/group-select/index.vue +++ b/src/views/property-marketing/media-account/components/group-select/index.vue @@ -9,6 +9,7 @@ size="medium" :placeholder="placeholder" allow-clear + :max-tag-count="3" @change="handleChange" > diff --git a/src/views/property-marketing/media-account/components/tag-select/index.vue b/src/views/property-marketing/media-account/components/tag-select/index.vue index 189e336..0ae6988 100644 --- a/src/views/property-marketing/media-account/components/tag-select/index.vue +++ b/src/views/property-marketing/media-account/components/tag-select/index.vue @@ -9,6 +9,7 @@ size="medium" :placeholder="placeholder" allow-clear + :max-tag-count="3" @change="handleChange" > diff --git a/src/views/property-marketing/put-account/account-data/components/filter-block/style.scss b/src/views/property-marketing/put-account/account-data/components/filter-block/style.scss index 191ada1..48e2115 100644 --- a/src/views/property-marketing/put-account/account-data/components/filter-block/style.scss +++ b/src/views/property-marketing/put-account/account-data/components/filter-block/style.scss @@ -1,18 +1,4 @@ .container { - :deep(.arco-input-wrapper), - :deep(.arco-select-view-single), - :deep(.arco-select-view-multiple), - :deep(.arco-picker) { - border-radius: 4px; - border-color: #d7d7d9; - background-color: #fff; - &:focus-within, - &.arco-input-focus { - background-color: var(--color-bg-2); - border-color: rgb(var(--primary-6)); - box-shadow: 0 0 0 0 var(--color-primary-light-2); - } - } .filter-row { .filter-row-item { &:not(:last-child) { diff --git a/src/views/property-marketing/put-account/account-data/components/group-select/index.vue b/src/views/property-marketing/put-account/account-data/components/group-select/index.vue index a736c92..f8e6556 100644 --- a/src/views/property-marketing/put-account/account-data/components/group-select/index.vue +++ b/src/views/property-marketing/put-account/account-data/components/group-select/index.vue @@ -9,6 +9,7 @@ size="medium" :placeholder="placeholder" allow-clear + :max-tag-count="3" @change="handleChange" > diff --git a/src/views/property-marketing/put-account/account-manage/components/account-table/index.vue b/src/views/property-marketing/put-account/account-manage/components/account-table/index.vue index e778bfe..1fcce8a 100644 --- a/src/views/property-marketing/put-account/account-manage/components/account-table/index.vue +++ b/src/views/property-marketing/put-account/account-manage/components/account-table/index.vue @@ -63,8 +63,8 @@ - - + + @@ -92,7 +92,7 @@ const props = defineProps({ }, }); -const emits = defineEmits(['openEdit', 'update', 'selectionChange', 'delete']); +const emits = defineEmits(['openEdit', 'selectionChange', 'delete']); const pauseAccountPatchModalRef = ref(null); const authorizedAccountModalRef = ref(null); @@ -121,7 +121,7 @@ const openDelete = (item) => { }; const handleReauthorize = (item) => { - authorizedAccountModalRef.value?.open(item.id, item.last_synced_at); + authorizedAccountModalRef.value?.open({ accountId: item.id, last_synced_at: item.last_synced_at }); }; const handlePause = (item) => { diff --git a/src/views/property-marketing/put-account/account-manage/components/account-table/pause-account-patch.vue b/src/views/property-marketing/put-account/account-manage/components/account-table/pause-account-patch.vue index 9649f20..7509a48 100644 --- a/src/views/property-marketing/put-account/account-manage/components/account-table/pause-account-patch.vue +++ b/src/views/property-marketing/put-account/account-manage/components/account-table/pause-account-patch.vue @@ -20,8 +20,8 @@ import { ref } from 'vue'; import { pausePatchPlacementAccount } from '@/api/all/propertyMarketing'; import icon1 from '@/assets/img/media-account/icon-warn-1.png'; -const emits = defineEmits(['update', 'close']); - +const emits = defineEmits(['close']); +const update = inject('update'); const visible = ref(false); const accountId = ref(null); const accountName = ref(''); @@ -45,7 +45,7 @@ async function onConfirm() { const { code } = await pausePatchPlacementAccount(accountId.value); if (code === 200) { AMessage.success('暂停成功'); - emits('update'); + update(); onClose(); } } diff --git a/src/views/property-marketing/put-account/account-manage/components/add-account-modal/index.vue b/src/views/property-marketing/put-account/account-manage/components/add-account-modal/index.vue index 021d701..64f2acd 100644 --- a/src/views/property-marketing/put-account/account-manage/components/add-account-modal/index.vue +++ b/src/views/property-marketing/put-account/account-manage/components/add-account-modal/index.vue @@ -137,7 +137,7 @@ - + @@ -148,7 +148,7 @@ import { ref, defineEmits } from 'vue'; import AuthorizedAccountModal from '../authorized-account-modal'; // import ImportPromptModal from '../import-prompt-modal'; import StatusBox from '../status-box'; -import { PLATFORM_LIST } from '@/views/property-marketing/put-account/common_constants'; +import { PLATFORM_LIST, ENUM_PLATFORM } from '@/views/property-marketing/put-account/common_constants'; import { postPlacementAccounts, @@ -161,7 +161,7 @@ import { import icon1 from '@/assets/img/media-account/icon-download.png'; import icon2 from '@/assets/img/media-account/icon-delete.png'; -const emits = defineEmits(['update']); +const update = inject('update'); const UploadStatus = { DEFAULT: 'default', @@ -278,7 +278,7 @@ const handleBatchImport = async () => { }); if (code === 200) { AMessage.success('导入成功'); - emits('update'); + update(); onClose(); } else { uploadStatus.value = UploadStatus.ERROR; @@ -290,6 +290,27 @@ const handleBatchImport = async () => { // importPromptModalRef.value.open(); }; +const handleAdd = async () => { + // 聚光无子账号 + if (form.value.platform === ENUM_PLATFORM.jg) { + const { code, data } = await postPlacementAccounts(form.value); + if (code === 200) { + update(); + authorizedAccountModalRef.value.open({ accountId: data?.id }); + } + } else { + authorizedAccountModalRef.value.open({ form: form.value, needSelectSubAccount: true }); + } +}; +const handleEdit = async () => { + const { code } = await putPlacementAccounts({ id: id.value, ...form.value }); + if (code === 200) { + isEdit.value && AMessage.success('修改成功'); + update(); + onClose(); + } +}; + async function onSubmit() { if (isBatchImport.value) { handleBatchImport(); @@ -298,27 +319,11 @@ async function onSubmit() { formRef.value.validate(async (errors) => { if (!errors) { - const _fn = id.value ? putPlacementAccounts : postPlacementAccounts; - const _params = id.value ? { id: id.value, ...form.value } : form.value; - const { code, data } = await _fn(_params); - if (code === 200) { - isEdit.value && AMessage.success('修改成功'); - emits('update'); - - if (isEdit.value) { - onClose(); - } else { - handleSuccess(data?.id); - } - } + isEdit.value ? handleEdit() : handleAdd(); } }); } -const handleSuccess = (id) => { - authorizedAccountModalRef.value.open(id); -}; - const handleDownloadTemplate = async () => { const { code, data } = await getPlacementAccountsTemplateUrl(); if (code === 200) { @@ -326,6 +331,7 @@ const handleDownloadTemplate = async () => { } }; +provide('closeAddAccountModal', onClose); // 对外暴露打开弹窗方法 defineExpose({ open }); diff --git a/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue b/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue index 4f5bb36..b3ce517 100644 --- a/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue +++ b/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue @@ -59,23 +59,28 @@ {{ confirmBtnText }} + + + + diff --git a/src/views/property-marketing/put-account/account-manage/components/select-sub-account-modal/style.scss b/src/views/property-marketing/put-account/account-manage/components/select-sub-account-modal/style.scss new file mode 100644 index 0000000..25d027e --- /dev/null +++ b/src/views/property-marketing/put-account/account-manage/components/select-sub-account-modal/style.scss @@ -0,0 +1,45 @@ +.select-sub-account-modal { + .cts { + color: var(--Text-1, #211f24); + font-family: $font-family-medium; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 22px; + } + .arco-modal-header { + } + .arco-modal-body { + height: 536px; + overflow: hidden; + display: flex; + flex-direction: column; + .filter-row { + .filter-row-item { + &:not(:last-child) { + margin-right: 24px; + } + .label { + margin-right: 12px; + color: #211f24; + font-family: 'PuHuiTi-Regular'; + font-size: 14px; + font-style: normal; + font-weight: 400; + flex-shrink: 0; + line-height: 22px; + } + } + } + + } + .arco-modal-footer { + justify-content: space-between; + .s1 { + font-family: $font-family-regular; + .num { + font-family: $font-family-medium; + } + } + } +} diff --git a/src/views/property-marketing/put-account/account-manage/index.vue b/src/views/property-marketing/put-account/account-manage/index.vue index d0b4a33..6099120 100644 --- a/src/views/property-marketing/put-account/account-manage/index.vue +++ b/src/views/property-marketing/put-account/account-manage/index.vue @@ -67,7 +67,6 @@ @selectionChange="handleSelectionChange" @delete="handleDelete" @openEdit="handleOpenEdit" - @update="getData" /> @@ -86,7 +85,7 @@ - + @@ -254,6 +253,8 @@ const handleOpenAbnormalAccount = () => { query.value.status = 2; reload(); }; + +provide('update', getData);