提交 d63a7eaa authored 作者: lidongxu's avatar lidongxu

refactor(mobile/plan): 促销计划_移动端_搜索 bug 排查修复

同上
上级 eb92797a
...@@ -49,9 +49,10 @@ ...@@ -49,9 +49,10 @@
<!-- 搜索组件 --> <!-- 搜索组件 -->
<PlanSearch v-model:show="showSearch" <PlanSearch v-model:show="showSearch"
v-model:query="query"
:planColumns="planColumns" :planColumns="planColumns"
:allEmpolyeeList="allEmpolyeeList" :allEmpolyeeList="allEmpolyeeList"
@query="getPlanList" /> @query="querySearch" />
</div> </div>
</template> </template>
...@@ -111,28 +112,28 @@ const getEmployeeList = async () => { ...@@ -111,28 +112,28 @@ const getEmployeeList = async () => {
}) })
} }
const getPlanList = async () => {
const getPlanList = async ({ activityStartDate, activityEndDate, planStatus, employeeId, storeNameLike } = {}) => { // 搜索条件改变/刷新时,页码重置为 1
!loading.value && (query.pageNum = 1)
const res = await getPlanListAPI({ const res = await getPlanListAPI({
...query, pageNum: query.pageNum,
pageSize: query.pageSize,
queryParams: { queryParams: {
activityStartDate: parseTime(activityStartDate, "{y}-{m}-{d}"), activityStartDate: parseTime(query.activityStartDate, "{y}-{m}-{d}"),
activityEndDate: parseTime(activityEndDate, "{y}-{m}-{d}"), activityEndDate: parseTime(query.activityEndDate, "{y}-{m}-{d}"),
planStatus: planColumns.find(item => item.text === planStatus)?.value, planStatus: planColumns.find(item => item.text === query.planStatus)?.value,
employeeId: promotionIdentity.value ? allEmpolyeeList.value.find(o => o.employeeNo === employeeNo.value)?.value : employeeId, employeeId: promotionIdentity.value ? allEmpolyeeList.value.find(o => o.employeeNo === employeeNo.value)?.value : query.employeeId,
storeNameLike storeNameLike: query.storeNameLike
}, },
}) })
if (loading.value) {
planList.value = [...planList.value, ...res.data.records] planList.value = [...planList.value, ...res.data.records]
finished.value = res.data.records.length === 0
loading.value = false loading.value = false
} else { refreshLoading.value = false
planList.value = res.data.records finished.value = res.data.records.length < query.pageSize
}
} }
// 加载更多
const onLoad = () => { const onLoad = () => {
loading.value = true loading.value = true
query.pageNum++ query.pageNum++
...@@ -144,11 +145,18 @@ const refreshLoading = ref(false) ...@@ -144,11 +145,18 @@ const refreshLoading = ref(false)
const onRefresh = () => { const onRefresh = () => {
setTimeout(async () => { setTimeout(async () => {
query.pageNum = 1 query.pageNum = 1
await getPlanList() planList.value = []
refreshLoading.value = false getPlanList()
}, 300) }, 300)
} }
// 搜索表单
const querySearch = () => {
query.pageNum = 1
planList.value = []
getPlanList()
}
// 编辑计划 // 编辑计划
const editPlan = (row) => { const editPlan = (row) => {
if (!checkPlanExpire(row)) { if (!checkPlanExpire(row)) {
......
...@@ -87,7 +87,6 @@ const employeeNo = computed(() => userStore().employeeNo) ...@@ -87,7 +87,6 @@ const employeeNo = computed(() => userStore().employeeNo)
const { recentPickerOptions: pickerOptions } = useDatePickerOptions() const { recentPickerOptions: pickerOptions } = useDatePickerOptions()
const query = reactive({})
const props = defineProps({ const props = defineProps({
planColumns: { // 活动状态列表 planColumns: { // 活动状态列表
type: Array, type: Array,
...@@ -96,56 +95,61 @@ const props = defineProps({ ...@@ -96,56 +95,61 @@ const props = defineProps({
allEmpolyeeList: { // 所有归属人 allEmpolyeeList: { // 所有归属人
type: Array, type: Array,
default: [] default: []
},
query: { // 搜索对象
type: Object,
default: () => { }
} }
}) })
const emits = defineEmits(['query']) const emits = defineEmits(['query'])
watch(query, () => {
emits('query', query)
}, { deep: true })
// 选择快捷日期 // 选择快捷日期
const pickerSelDate = (item) => { const pickerSelDate = (item) => {
let [startTime, endTime] = item.value() // 拿到日期对象 let [startTime, endTime] = item.value() // 拿到日期对象
// 同步更新单独选择日期的选择器和参数 // 同步更新单独选择日期的选择器和参数
query.activityStartDate = startTime props.query.activityStartDate = startTime
query.activityEndDate = endTime props.query.activityEndDate = endTime
emits('query')
} }
// 选择日期区间 // 选择日期区间
const showCalendar = ref(false) const showCalendar = ref(false)
const searchDateStr = computed(() => { const searchDateStr = computed(() => {
if (!query.activityStartDate || !query.activityEndDate) { if (!props.query.activityStartDate || !props.query.activityEndDate) {
return '' return ''
} }
return [query.activityStartDate, query.activityEndDate].map(o => parseTime(o, "{y}-{m}-{d}")).join(' 至 ') return [props.query.activityStartDate, props.query.activityEndDate].map(o => parseTime(o, "{y}-{m}-{d}")).join(' 至 ')
}) })
// 日历最小范围 // 日历最小范围
const searchMinDate = computed(() => { const searchMinDate = computed(() => {
return new Date(!query.activityStartDate ? new Date().getFullYear() - 1 : query.activityStartDate.getFullYear() - 1, 0, 1) return new Date(!props.query.activityStartDate ? new Date().getFullYear() - 1 : props.query.activityStartDate.getFullYear() - 1, 0, 1)
}) })
// 日期日历范围 // 日期日历范围
const selSearchCalendar = () => { const selSearchCalendar = () => {
// 默认设置今日日期 // 默认设置今日日期
if (!query.activityStartDate || !query.activityEndDate) { if (!props.query.activityStartDate || !props.query.activityEndDate) {
query.activityStartDate = new Date() props.query.activityStartDate = new Date()
query.activityEndDate = new Date() props.query.activityEndDate = new Date()
} }
showCalendar.value = true showCalendar.value = true
} }
// 确定日期 // 确定日期
const confirmCalendar = (value) => { const confirmCalendar = (value) => {
showCalendar.value = false showCalendar.value = false
query.activityStartDate = value[0] props.query.activityStartDate = value[0]
query.activityEndDate = value[1] props.query.activityEndDate = value[1]
emits('query')
} }
// 活动状态 // 活动状态
const showPlanStatus = ref(false) const showPlanStatus = ref(false)
// 选中的活动状态 // 选中的活动状态
const confirmPlan = (val) => { const confirmPlan = (val) => {
query.planStatus = val.selectedOptions[0].text props.query.planStatus = val.selectedOptions[0].text
showPlanStatus.value = false showPlanStatus.value = false
emits('query')
} }
// 归属人 // 归属人
...@@ -158,7 +162,7 @@ watch(() => props.allEmpolyeeList, (newValue) => { ...@@ -158,7 +162,7 @@ watch(() => props.allEmpolyeeList, (newValue) => {
if (promotionIdentity.value) { if (promotionIdentity.value) {
// 找到员工的 id // 找到员工的 id
const obj = newValue.find(o => o.employeeNo === employeeNo.value) const obj = newValue.find(o => o.employeeNo === employeeNo.value)
query.employeeId = obj.value props.query.employeeId = obj.value
} }
}) })
// 搜索归属人 // 搜索归属人
...@@ -169,22 +173,26 @@ const searchEmployee = (searchName) => { ...@@ -169,22 +173,26 @@ const searchEmployee = (searchName) => {
} }
// 确定归属人 // 确定归属人
const onEmployeeConfirm = (val) => { const onEmployeeConfirm = (val) => {
query.employeeId = val.selectedOptions[0].value props.query.employeeId = val.selectedOptions[0].value
showEmployee.value = false showEmployee.value = false
emits('query')
} }
// 店铺名 // 店铺名
const searchByStoreName = (val) => { const searchByStoreName = (val) => {
query.storeNameLike = val props.query.storeNameLike = val
emits('query')
} }
// 重置 // 重置
const resetFn = () => { const resetFn = () => {
query.activityStartDate = '' props.query.pageNum = 1
query.activityEndDate = '' props.query.activityStartDate = ''
query.planStatus = '' props.query.activityEndDate = ''
!promotionIdentity.value && (query.employeeId = '') props.query.planStatus = undefined
query.storeNameLike = '' !promotionIdentity.value && (props.query.employeeId = undefined)
props.query.storeNameLike = undefined
emits('query')
} }
</script> </script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论