| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- <template>
- <div class="container">
- <Breadcrumb :items="['menu.taobao', 'menu.taobao.orders']" />
- <a-card class="general-card" :title="$t('menu.taobao.orders')">
- <a-row>
- <a-col :flex="1">
- <a-form :model="formModel" :label-col-props="{ span: 8 }" :wrapper-col-props="{ span: 16 }"
- label-align="left">
- <a-row :gutter="24">
- <a-col :span="6">
- <a-form-item field="name" label="账号名">
- <selectAccount v-model="formModel.keyword" @change="changeCompany" />
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item field="tkStatus" label="订单状态">
- <a-select :model="formModel.tkStatus" @change="changeStatus">
- <a-option :value="0">所有状态</a-option>
- <a-option :value="3">已结算</a-option>
- <a-option :value="12">已付款</a-option>
- <a-option :value="13">已失效</a-option>
- <a-option :value="14">已收货</a-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item field="query_date" :label="$t('searchTable.form.order_date')">
- <a-range-picker v-model="formModel.query_date" style="width: 100%"
- @change="changeDate" />
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item field="maxTotal" label="最大记录">
- <a-select v-model="formModel.maxTotal">
- <a-option :value="1000">1000</a-option>
- <a-option :value="10000">10000</a-option>
- <a-option :value="100000">10W</a-option>
- <a-option :value="1000000">100W</a-option>
- <a-option :value="10000000">1000W</a-option>
- </a-select>
- </a-form-item>
- </a-col>
- </a-row>
- </a-form>
- </a-col>
- <a-divider style="height: 32px" direction="vertical" />
- <a-col :flex="'86px'" style="text-align: right">
- <a-space direction="vertical" :size="18">
- <a-button type="primary" @click="search">
- <template #icon>
- <icon-search />
- </template>
- {{ $t('searchTable.form.search') }}
- </a-button>
- </a-space>
- </a-col>
- </a-row>
- <a-divider style="margin-top: 0" />
- <a-row style="margin-bottom: 16px">
- <a-col :span="12"> </a-col>
- <a-col :span="12" style="
- display: flex;
- align-items: center;
- justify-content: end;
- ">
- <a-tooltip :content="$t('searchTable.actions.refresh')">
- <div class="action-icon" @click="search"><icon-refresh size="18" /></div>
- </a-tooltip>
- <a-dropdown @select="handleSelectDensity">
- <a-tooltip :content="$t('searchTable.actions.density')">
- <div class="action-icon"><icon-line-height size="18" /></div>
- </a-tooltip>
- <template #content>
- <a-doption v-for="item in densityList" :key="item.value" :value="item.value"
- :class="{ active: item.value === size }">
- <span>{{ item.name }}</span>
- </a-doption>
- </template>
- </a-dropdown>
- <a-tooltip :content="$t('searchTable.actions.columnSetting')">
- <a-popover trigger="click" position="bl" @popup-visible-change="popupVisibleChange">
- <div class="action-icon"><icon-settings size="18" /></div>
- <template #content>
- <div id="tableSetting">
- <div v-for="(item, index) in showColumns" :key="item.dataIndex" class="setting">
- <div style="
- margin-right: 4px;
- cursor: move;
- ">
- <icon-drag-arrow />
- </div>
- <div>
- <a-checkbox v-model="item.checked" @change="
- handleChange(
- $event,
- item as TableColumnData,
- index
- )
- ">
- </a-checkbox>
- </div>
- <div class="title">
- {{
- item.title === '#'
- ? '序列号'
- : item.title
- }}
- </div>
- </div>
- </div>
- </template>
- </a-popover>
- </a-tooltip>
- </a-col>
- </a-row>
- <a-table row-key="id" :loading="loading" :pagination="pagination"
- :columns="(cloneColumns as TableColumnData[])" :scroll="scroll" :scrollbar="scrollbar"
- :data="renderData" :bordered="false" :size="size" @page-change="onPageChange">
- <template #orderInfo="{ record }">
- <a-list-item>
- <a-list-item-meta>
- <template #avatar>
- <a-avatar shape="square">
- <img alt="avatar" :src="record.itemImg" />
- </a-avatar>
- </template>
- <template #title>
- <a target="_blank" class="link" :href="record.mktItemLink">
- {{ record.itemTitle }}
- </a>
- </template>
- <template #description>
- <div class="text-3">
- <div>店铺名:{{ record.sellerShopTitle }}
- <a-tooltip>
- <a-tag>{{ record.tradeId }}</a-tag>
- <template #content>
- <div>父订单编号:{{ record.tradeParentId }}</div>
- <div> 子订单编号:{{ record.tradeId }}</div>
- </template>
- </a-tooltip>
- </div>
- <div> {{ record.tbPaidTime }}付款 </div>
- <div v-if="record.tkEarningTime != '0001-01-01 00:00:00'">
- {{ record.tkEarningTime }}结算
- </div>
- </div>
- </template>
- </a-list-item-meta>
- </a-list-item>
- </template>
- <template #alipayTotalPrice="{ record }">
- <span>¥{{ record.alipayTotalPrice }}</span>
- </template>
- <template #tkTotalRateForCommissionAndSdy="{ record }">
- {{ record.tkTotalRateForCommissionAndSdy }}%
- </template>
- <template #pubSharePreFee="{ record }">
- <div class="text-3">
- <div>付款预估佣金收入:<span class="money-sum">¥{{ record.pubSharePreFeeForCommission }}</span></div>
- <div>付款预估补贴收入:<span class="money-sum">¥{{ record.pubSharePreFeeForSdy }}</span></div>
- </div>
- </template>
- <template #totalCommissionFee="{ record }">
- <div class="text-3">
- <div>付款预估佣金收入:<span class="money-sum">¥{{ record.pubShareFeeForCommission }}</span></div>
- <div>付款预估补贴收入:<span class="money-sum">¥{{ record.pubShareFeeForSdy }}</span></div>
- </div>
- </template>
- <template #alimamaShareFee="{ record }">
- <div>¥{{ record.alimamaShareFee }}</div>
- </template>
- <template #last_time="{ record }">
- <div class="money-sum">{{ record.last_time }}</div>
- </template>
- </a-table>
- </a-card>
- </div>
- </template>
- <script lang="ts" setup>
- import { useRouter } from 'vue-router';
- import dayjs from 'dayjs';
- import { computed, ref, reactive, watch, nextTick } from 'vue';
- import { useI18n } from 'vue-i18n';
- import useLoading from '@/hooks/loading';
- import {
- queryTkOrders,
- TkOrderRecord,
- TkOrdersParams,
- } from '@/api/taobao';
- import { Pagination } from '@/types/global';
- import type {
- TableData,
- TableColumnData,
- } from '@arco-design/web-vue/es/table/interface';
- import cloneDeep from 'lodash/cloneDeep';
- import Sortable from 'sortablejs';
- import selectAccount from './components/selectAccount.vue';
- type SizeProps = 'mini' | 'small' | 'medium' | 'large';
- type Column = TableColumnData & { checked?: true };
- const generateFormModel = () => {
- return {
- keyword: '',
- tkStatus: 0,
- formModel: 1000,
- query_date: [],
- current: 1,
- pageSize: 20,
- maxTotal: 1000,
- sort: 'tkPaidTime',
- order: 'descending',
- };
- };
- const router = useRouter();
- const { loading, setLoading } = useLoading(true);
- const { t } = useI18n();
- const renderData = ref<TkOrderRecord[]>([]);
- const formModel = ref(generateFormModel());
- const cloneColumns = ref<Column[]>([]);
- const showColumns = ref<Column[]>([]);
- const size = ref<SizeProps>('medium');
- const scrollbar = ref(true);
- const scroll = {
- x: '100%',
- y: '100%',
- maxHeight: 'calc( 100vh - 420px)',
- };
- const basePagination: Pagination = {
- current: 1,
- pageSize: 20,
- };
- const pagination = reactive({
- ...basePagination,
- });
- const densityList = computed(() => [
- {
- name: t('searchTable.size.mini'),
- value: 'mini',
- },
- {
- name: t('searchTable.size.small'),
- value: 'small',
- },
- {
- name: t('searchTable.size.medium'),
- value: 'medium',
- },
- {
- name: t('searchTable.size.large'),
- value: 'large',
- },
- ]);
- const columns = computed<TableColumnData[]>(() => [
- {
- title: '订单信息',
- dataIndex: 'xAxis',
- slotName: 'orderInfo',
- fixed: 'left',
- width: 450,
- },
- {
- title: '订单状态',
- dataIndex: 'tkStatusText',
- width: 120,
- },
- {
- title: '订单金额',
- slotName: 'alipayTotalPrice',
- width: 100,
- align: 'right'
- },
- {
- title: '总提成率',
- dataIndex: 'tkTotalRateForCommissionAndSdy',
- slotName: 'tkTotalRateForCommissionAndSdy',
- width: 120,
- align: 'right'
- },
- {
- title: '付款预估收入',
- dataIndex: 'pubSharePreFee',
- slotName: 'pubSharePreFee',
- width: 220,
- align: 'right'
- },
- {
- title: '结算预估收入',
- dataIndex: 'totalCommissionFee',
- slotName: 'totalCommissionFee',
- width: 220,
- align: 'right'
- },
- {
- title: '平台技术服务费',
- dataIndex: 'alimamaShareFee',
- slotName: 'alimamaShareFee',
- width: 140,
- align: 'right'
- },
- {
- title: '最后更新时间',
- dataIndex: 'last_time',
- slotName: 'last_time',
- width: 100,
- align: 'right'
- },
- ]);
- // renderData.value.tkStatusText
- const fetchData = async (
- params: TkOrdersParams = {
- current: 1,
- pageSize: 20,
- maxTotal: 1000,
- sort: 'tkPaidTime',
- order: 'descending',
- }
- ) => {
- setLoading(true);
- try {
- const { data } = await queryTkOrders(params);
- console.log(data);
- if (!data) return;
- renderData.value = data.list;
- pagination.current = data.page;
- pagination.total = data.count;
- console.log(data);
- } catch (err) {
- console.log(err);
- } finally {
- setLoading(false);
- }
- };
- const search = () => {
- fetchData({
- ...basePagination,
- ...formModel.value,
- } as unknown as TkOrdersParams);
- };
- const onPageChange = (current: number) => {
- fetchData({
- ...basePagination,
- ...formModel.value,
- current
- });
- };
- fetchData();
- const reset = () => {
- formModel.value = generateFormModel();
- };
- const changeCompany = (value: any) => {
- const reset = () => {
- formModel.value = generateFormModel();
- };
- formModel.value.keyword = value
- fetchData({
- ...basePagination,
- ...formModel.value,
- } as unknown as TkOrdersParams);
- };
- const changeStatus = (value: any) => {
- const reset = () => {
- formModel.value = generateFormModel();
- };
- console.log(value)
- formModel.value.tkStatus = value
- fetchData({
- ...basePagination,
- ...formModel.value,
- } as unknown as TkOrdersParams);
- };
- const changeDate = (value: any) => {
- const reset = () => {
- formModel.value = generateFormModel();
- };
- formModel.value.query_date = value
- fetchData({
- ...basePagination,
- ...formModel.value,
- } as unknown as TkOrdersParams);
- };
- const handleSelectDensity = (
- val: string | number | Record<string, any> | undefined,
- e: Event
- ) => {
- size.value = val as SizeProps;
- };
- const handleChange = (
- checked: boolean | (string | boolean | number)[],
- column: Column,
- index: number
- ) => {
- if (!checked) {
- cloneColumns.value = showColumns.value.filter(
- (item) => item.dataIndex !== column.dataIndex
- );
- } else {
- cloneColumns.value.splice(index, 0, column);
- }
- };
- const exchangeArray = <T extends Array<any>>(
- array: T,
- beforeIdx: number,
- newIdx: number,
- isDeep = false
- ): T => {
- const newArray = isDeep ? cloneDeep(array) : array;
- if (beforeIdx > -1 && newIdx > -1) {
- // 先替换后面的,然后拿到替换的结果替换前面的
- newArray.splice(
- beforeIdx,
- 1,
- newArray.splice(newIdx, 1, newArray[beforeIdx]).pop()
- );
- }
- return newArray;
- };
- const popupVisibleChange = (val: boolean) => {
- if (val) {
- nextTick(() => {
- const el = document.getElementById(
- 'tableSetting'
- ) as HTMLElement;
- const sortable = new Sortable(el, {
- onEnd(e: any) {
- const { oldIndex, newIndex } = e;
- exchangeArray(cloneColumns.value, oldIndex, newIndex);
- exchangeArray(showColumns.value, oldIndex, newIndex);
- },
- });
- });
- }
- };
- watch(
- () => columns.value,
- (val) => {
- cloneColumns.value = cloneDeep(val);
- cloneColumns.value.forEach((item, index) => {
- item.checked = true;
- });
- showColumns.value = cloneDeep(cloneColumns.value);
- },
- { deep: true, immediate: true }
- );
- </script>
- <script lang="ts">
- export default {
- name: 'tkOrders',
- };
- </script>
- <style scoped lang="less">
- .container {
- padding: 0 20px 20px 20px;
- }
- :deep(.arco-table-th) {
- &:last-child {
- .arco-table-th-item-title {
- margin-left: 16px;
- }
- }
- }
- .action-icon {
- margin-left: 12px;
- cursor: pointer;
- }
- .active {
- color: #0960bd;
- background-color: #e3f4fc;
- }
- .setting {
- display: flex;
- align-items: center;
- width: 200px;
- .title {
- margin-left: 12px;
- cursor: pointer;
- }
- }
- .arco-table-td,
- .arco-table-td div,
- .arco-table-td span {
- font-size: 12px !important;
- }
- .text-3 {
- color: var(--color-text-3);
- }
- .money-sum {
- color: var(--color-text-2) !important;
- }
- .link {
- color: var(--color-text-t);
- text-decoration: none;
- }
- .link:hover {
- color: blue;
- text-decoration: underline;
- }
- </style>
|