- 添加 .editorconfig 文件统一代码风格 - 添加 .env.development 和 .env.example 环境配置文件 - 添加 .eslintignore 和 .eslintrc.js 代码检查配置 - 添加 .gitignore 版本控制忽略文件配置 - 添加 .prettierignore 格式化忽略配置 - 添加隐私协议HTML文件 - 添加API密钥管理组件基础结构
266 lines
7.2 KiB
Vue
266 lines
7.2 KiB
Vue
<!-- 搜索表单 -->
|
|
<template>
|
|
<a-space :size="10" style="flex-wrap: wrap">
|
|
<!-- <a-button-->
|
|
<!-- danger-->
|
|
<!-- type="primary"-->
|
|
<!-- class="ele-btn-icon"-->
|
|
<!-- :disabled="selection?.length === 0"-->
|
|
<!-- @click="removeBatch"-->
|
|
<!-- >-->
|
|
<!-- <template #icon>-->
|
|
<!-- <DeleteOutlined/>-->
|
|
<!-- </template>-->
|
|
<!-- <span>批量删除</span>-->
|
|
<!-- </a-button>-->
|
|
<a-input-search
|
|
allow-clear
|
|
v-model:value="where.orderNo"
|
|
placeholder="订单编号"
|
|
style="width: 240px"
|
|
@search="reload"
|
|
@pressEnter="reload"
|
|
/>
|
|
<a-select
|
|
v-model:value="where.type"
|
|
style="width: 150px"
|
|
placeholder="订单类型"
|
|
@change="search"
|
|
>
|
|
<a-select-option value="">全部</a-select-option>
|
|
<a-select-option :value="1">普通订单</a-select-option>
|
|
<a-select-option :value="2">秒杀订单</a-select-option>
|
|
<a-select-option :value="3">拼团订单</a-select-option>
|
|
</a-select>
|
|
<a-select
|
|
v-model:value="where.payStatus"
|
|
style="width: 150px"
|
|
placeholder="付款状态"
|
|
@change="search"
|
|
>
|
|
<a-select-option value="">全部</a-select-option>
|
|
<a-select-option :value="1">已付款</a-select-option>
|
|
<a-select-option :value="0">未付款</a-select-option>
|
|
</a-select>
|
|
<!-- <a-select-->
|
|
<!-- v-model:value="where.orderStatus"-->
|
|
<!-- style="width: 150px"-->
|
|
<!-- placeholder="订单状态"-->
|
|
<!-- @change="search"-->
|
|
<!-- >-->
|
|
<!-- <a-select-option value="">全部</a-select-option>-->
|
|
<!-- <a-select-option :value="1">已完成</a-select-option>-->
|
|
<!-- <a-select-option :value="0">未完成</a-select-option>-->
|
|
<!-- <a-select-option :value="2">未使用</a-select-option>-->
|
|
<!-- <a-select-option :value="3">已取消</a-select-option>-->
|
|
<!-- <a-select-option :value="4">退款中</a-select-option>-->
|
|
<!-- <a-select-option :value="5">退款被拒</a-select-option>-->
|
|
<!-- <a-select-option :value="6">退款成功</a-select-option>-->
|
|
<!-- </a-select>-->
|
|
<a-select
|
|
:options="getPayType()"
|
|
v-model:value="where.payType"
|
|
style="width: 150px"
|
|
placeholder="付款方式"
|
|
@change="search"
|
|
/>
|
|
|
|
<a-range-picker
|
|
v-model:value="dateRange"
|
|
@change="search"
|
|
value-format="YYYY-MM-DD"
|
|
/>
|
|
<a-input-search
|
|
allow-clear
|
|
:placeholder="getSearchPlaceholder()"
|
|
style="width: 320px"
|
|
v-model:value="where.keywords"
|
|
@search="reload"
|
|
>
|
|
<template #addonBefore>
|
|
<a-select v-model:value="type" style="width: 88px" @change="onType">
|
|
<a-select-option value="">不限</a-select-option>
|
|
<a-select-option value="userId"> 用户ID </a-select-option>
|
|
<a-select-option value="phone"> 手机号 </a-select-option>
|
|
<a-select-option value="nickname"> 昵称 </a-select-option>
|
|
</a-select>
|
|
</template>
|
|
</a-input-search>
|
|
<a-button @click="reset">重置</a-button>
|
|
<a-button @click="handleExport">导出</a-button>
|
|
</a-space>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref, watch } from 'vue';
|
|
import { utils, writeFile } from 'xlsx';
|
|
import { message } from 'ant-design-vue';
|
|
import useSearch from '@/utils/use-search';
|
|
import { ShopOrder, ShopOrderParam } from '@/api/shop/shopOrder/model';
|
|
import { listShopOrder } from '@/api/shop/shopOrder';
|
|
import { getPayType } from '@/utils/shop';
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
// 选中的订单
|
|
selection?: ShopOrder[];
|
|
}>(),
|
|
{}
|
|
);
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'search', where?: ShopOrderParam): void;
|
|
(e: 'add'): void;
|
|
(e: 'remove'): void;
|
|
(e: 'batchMove'): void;
|
|
}>();
|
|
|
|
// 表单数据
|
|
const { where, resetFields } = useSearch<ShopOrderParam>({
|
|
keywords: '',
|
|
orderId: undefined,
|
|
orderNo: undefined,
|
|
createTimeStart: undefined,
|
|
createTimeEnd: undefined,
|
|
userId: undefined,
|
|
payUserId: undefined,
|
|
nickname: undefined,
|
|
phone: undefined,
|
|
payStatus: undefined,
|
|
orderStatus: undefined,
|
|
payType: undefined
|
|
});
|
|
|
|
const reload = () => {
|
|
emit('search', {
|
|
...where,
|
|
keywords: type.value == '' ? where.keywords : undefined
|
|
});
|
|
};
|
|
|
|
// 批量删除
|
|
// const removeBatch = () => {
|
|
// emit('remove');
|
|
// };
|
|
|
|
const onType = () => {
|
|
resetFields();
|
|
};
|
|
|
|
// 获取搜索框placeholder
|
|
const getSearchPlaceholder = () => {
|
|
switch (type.value) {
|
|
case 'userId':
|
|
where.userId = Number(where.keywords);
|
|
return '请输入用户ID';
|
|
case 'phone':
|
|
where.phone = where.keywords;
|
|
return '请输入手机号';
|
|
case 'nickname':
|
|
where.nickname = where.keywords;
|
|
return '请输入用户昵称';
|
|
default:
|
|
return '请输入搜索内容';
|
|
}
|
|
};
|
|
|
|
/* 搜索 */
|
|
const search = () => {
|
|
const [d1, d2] = dateRange.value ?? [];
|
|
xlsFileName.value = `${d1}至${d2}`;
|
|
where.createTimeStart = d1 ? d1 + ' 00:00:00' : undefined;
|
|
where.createTimeEnd = d2 ? d2 + ' 23:59:59' : undefined;
|
|
emit('search', {
|
|
...where
|
|
});
|
|
};
|
|
|
|
/* 重置 */
|
|
const reset = () => {
|
|
resetFields();
|
|
search();
|
|
};
|
|
|
|
const dateRange = ref<[string, string]>(['', '']);
|
|
// 变量
|
|
const loading = ref(false);
|
|
const orders = ref<ShopOrder[]>([]);
|
|
const xlsFileName = ref<string>();
|
|
const type = ref('');
|
|
|
|
// 导出
|
|
const handleExport = async () => {
|
|
loading.value = true;
|
|
const array: (string | number)[][] = [
|
|
[
|
|
'订单编号',
|
|
'订单标题',
|
|
'买家姓名',
|
|
'手机号码',
|
|
'实付金额(元)',
|
|
'支付方式',
|
|
'付款时间',
|
|
'下单时间'
|
|
]
|
|
];
|
|
|
|
await listShopOrder(where)
|
|
.then((list) => {
|
|
orders.value = list;
|
|
list?.forEach((d: ShopOrder) => {
|
|
array.push([
|
|
`${d.orderNo}`,
|
|
`${d.comments}`,
|
|
`${d.realName}`,
|
|
`${d.phone}`,
|
|
`${d.payPrice}`,
|
|
`${getPayType(d.payType)}`,
|
|
`${d.payTime || ''}`,
|
|
`${d.createTime}`
|
|
]);
|
|
});
|
|
const sheetName = `订单数据`;
|
|
const workbook = {
|
|
SheetNames: [sheetName],
|
|
Sheets: {}
|
|
};
|
|
const sheet = utils.aoa_to_sheet(array);
|
|
workbook.Sheets[sheetName] = sheet;
|
|
// 设置列宽
|
|
sheet['!cols'] = [
|
|
{ wch: 10 },
|
|
{ wch: 40 },
|
|
{ wch: 20 },
|
|
{ wch: 20 },
|
|
{ wch: 60 },
|
|
{ wch: 15 },
|
|
{ wch: 10 },
|
|
{ wch: 10 },
|
|
{ wch: 20 },
|
|
{ wch: 10 },
|
|
{ wch: 20 }
|
|
];
|
|
message.loading('正在导出...');
|
|
setTimeout(() => {
|
|
writeFile(
|
|
workbook,
|
|
`${
|
|
where.createTimeEnd ? xlsFileName.value + '_' : ''
|
|
}${sheetName}.xlsx`
|
|
);
|
|
loading.value = false;
|
|
}, 1000);
|
|
})
|
|
.catch((msg) => {
|
|
message.error(msg);
|
|
loading.value = false;
|
|
})
|
|
.finally(() => {});
|
|
};
|
|
|
|
watch(
|
|
() => props.selection,
|
|
() => {}
|
|
);
|
|
</script>
|