Skip to content

Commit 615763d

Browse files
author
puhui999
committed
order:完善订单聚合搜索
1 parent 7e511d1 commit 615763d

File tree

1 file changed

+50
-32
lines changed

1 file changed

+50
-32
lines changed

src/views/mall/trade/order/index.vue

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@
104104
<el-form-item label="聚合搜索">
105105
<el-input
106106
v-show="true"
107-
v-model="queryType.v"
107+
v-model="queryParams[queryType.k]"
108108
class="!w-280px"
109109
clearable
110110
placeholder="请输入"
111111
>
112112
<template #prepend>
113-
<el-select v-model="queryType.k" class="!w-110px" clearable placeholder="全部">
113+
<el-select
114+
v-model="queryType.k"
115+
class="!w-110px"
116+
clearable
117+
placeholder="全部"
118+
@change="inputChangeSelect"
119+
>
114120
<el-option
115121
v-for="dict in searchList"
116122
:key="dict.value"
@@ -335,41 +341,41 @@ const total = ref(2) // 列表的总页数
335341
const list = ref<TradeOrderApi.OrderVO[]>([]) // 列表的数据
336342
const queryFormRef = ref<FormInstance>() // 搜索的表单
337343
// 表单搜索
338-
const queryParams = reactive({
339-
pageNo: 1, //首页
340-
pageSize: 10, //页面大小
341-
no: '',
342-
userId: '',
343-
userNickname: '',
344-
userMobile: '',
345-
receiverName: '',
346-
receiverMobile: '',
347-
348-
terminal: '',
349-
type: null,
350-
status: null,
351-
payChannelCode: '',
352-
createTime: [],
353-
deliveryType: null,
354-
spuName: '',
355-
itemCount: '',
356-
pickUpStoreId: [],
357-
logisticsId: null,
358-
all: ''
344+
const queryParams = ref({
345+
pageNo: 1, // 页数
346+
pageSize: 10, // 每页显示数量
347+
status: null, // 订单状态
348+
payChannelCode: null, // 支付方式
349+
createTime: null, // 创建时间
350+
terminal: null, // 订单来源
351+
type: null, // 订单类型
352+
deliveryType: null, // 配送方式
353+
logisticsId: null, // 快递公司
354+
pickUpStoreId: null // 自提门店
359355
})
360-
const queryType = reactive({ k: '', v: '' }) // 订单搜索类型kv
361-
/**
362-
* 订单聚合搜索
363-
* 商品名称、商品件数、全部
364-
*
365-
* 需要后端支持 TODO
366-
*/
356+
const queryType = reactive({ k: '' }) // 订单搜索类型 k
357+
358+
// 订单聚合搜索 select 类型配置
367359
const searchList = ref([
368360
{ value: 'no', label: '订单号' },
369361
{ value: 'userId', label: '用户UID' },
370362
{ value: 'userNickname', label: '用户昵称' },
371363
{ value: 'userMobile', label: '用户电话' }
372364
])
365+
/**
366+
* 聚合搜索切换查询对象时触发
367+
* @param val
368+
*/
369+
const inputChangeSelect = (val: string) => {
370+
searchList.value
371+
.filter((item) => item.value !== val)
372+
?.forEach((item1) => {
373+
// 清除集合搜索无用属性
374+
if (queryParams.value.hasOwnProperty(item1.value)) {
375+
delete queryParams.value[item1.value]
376+
}
377+
})
378+
}
373379
374380
const headerStyle = ({ row, columnIndex }: any) => {
375381
// 表头第一行第一列占 8
@@ -417,7 +423,7 @@ const spanMethod = ({ row, rowIndex, columnIndex }: SpanMethodProps) => {
417423
const getList = async () => {
418424
loading.value = true
419425
try {
420-
const data = await TradeOrderApi.getOrderPage(queryParams)
426+
const data = await TradeOrderApi.getOrderPage(unref(queryParams))
421427
list.value = data.list
422428
total.value = data.total
423429
} finally {
@@ -427,13 +433,25 @@ const getList = async () => {
427433
428434
/** 搜索按钮操作 */
429435
const handleQuery = async () => {
430-
queryParams.pageNo = 1
436+
queryParams.value.pageNo = 1
431437
await getList()
432438
}
433439
434440
/** 重置按钮操作 */
435441
const resetQuery = () => {
436442
queryFormRef.value?.resetFields()
443+
queryParams.value = {
444+
pageNo: 1, // 页数
445+
pageSize: 10, // 每页显示数量
446+
status: null, // 订单状态
447+
payChannelCode: null, // 支付方式
448+
createTime: null, // 创建时间
449+
terminal: null, // 订单来源
450+
type: null, // 订单类型
451+
deliveryType: null, // 配送方式
452+
logisticsId: null, // 快递公司
453+
pickUpStoreId: null // 自提门店
454+
}
437455
handleQuery()
438456
}
439457

0 commit comments

Comments
 (0)