Commit 9019f48c by 张立顺

feat 联调修改

1 parent ae7122fa
...@@ -496,6 +496,25 @@ export function getMonthDateRange(targetMonth) { ...@@ -496,6 +496,25 @@ export function getMonthDateRange(targetMonth) {
} }
/** /**
* 解析归属周期展示字符串为 [startDate, endDate]
* 支持 2026/05/01-2026/05/15 与 2026-05-01-2026-05-15
* @param {string} periodDateStr
* @returns {[string, string] | null}
*/
export function parsePeriodDateStr(periodDateStr) {
if (!periodDateStr) return null;
const slashMatch = periodDateStr.match(/^(\d{4}\/\d{2}\/\d{2})-(\d{4}\/\d{2}\/\d{2})$/);
if (slashMatch) {
return [slashMatch[1].replace(/\//g, "-"), slashMatch[2].replace(/\//g, "-")];
}
const dashMatch = periodDateStr.match(/^(\d{4}-\d{2}-\d{2})-(\d{4}-\d{2}-\d{2})$/);
if (dashMatch) {
return [dashMatch[1], dashMatch[2]];
}
return null;
}
/**
* 店面配置-门店主机厂交付数导入 * 店面配置-门店主机厂交付数导入
* 限制:当前日期>20号:仅允许选择当前月份;当前日期≤20号:允许选择当前月份和上个月 * 限制:当前日期>20号:仅允许选择当前月份;当前日期≤20号:允许选择当前月份和上个月
*/ */
......
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<script> <script>
import { Util, deepClone } from '@/common/util' import { Util, deepClone } from '@/common/util'
import { limitPrice, rangePickerOptions_deliveryQuantity, getMonthDateRange } from '@/common/format' import { limitPrice, rangePickerOptions_deliveryQuantity, getMonthDateRange, parsePeriodDateStr } from '@/common/format'
import { getList } from "@api/merchant" import { getList } from "@api/merchant"
import { outputValue_operTypeOpt } from "@/common/constants.js" import { outputValue_operTypeOpt } from "@/common/constants.js"
import { insertDeliverTargeConfig, updateDeliverTargeConfig, getById_deliver, getCarBrand } from '@api/shopConfig' import { insertDeliverTargeConfig, updateDeliverTargeConfig, getById_deliver, getCarBrand } from '@api/shopConfig'
...@@ -385,18 +385,21 @@ export default { ...@@ -385,18 +385,21 @@ export default {
fillPeriodRange() { fillPeriodRange() {
if (this.operationType === 'detail') return if (this.operationType === 'detail') return
let start = ''
let end = ''
if (this.formData.periodStartDate && this.formData.periodEndDate) { if (this.formData.periodStartDate && this.formData.periodEndDate) {
this.formData.periodRange = [this.formData.periodStartDate, this.formData.periodEndDate] start = Util.dateFormate(this.formData.periodStartDate, 'YYYY-MM-DD')
return end = Util.dateFormate(this.formData.periodEndDate, 'YYYY-MM-DD')
} } else if (this.formData.periodDateStr) {
if (this.formData.periodDateStr) { const parsed = parsePeriodDateStr(this.formData.periodDateStr)
const parts = this.formData.periodDateStr.split('-') if (parsed) {
if (parts.length >= 2) { start = parsed[0]
const start = parts[0].replace(/\//g, '-') end = parsed[1]
const end = parts.slice(1).join('-').replace(/\//g, '-')
this.formData.periodRange = [start, end]
} }
} }
if (start && end) {
this.$set(this.formData, 'periodRange', [start, end])
}
}, },
handleTargetMonthChange() { handleTargetMonthChange() {
......
<!-- 归属周期:日期区间 + 全月 --> <!-- 归属周期:开始固定1号 + 结束日期 + 全月 -->
<template> <template>
<div class="period-date-range"> <div class="period-date-range">
<el-date-picker v-model="innerRange" <el-date-picker :value="startDate"
type="daterange" type="date"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
format="yyyy/MM/dd" format="yyyy/MM/dd"
placeholder="开始日期"
disabled
class="period-picker start-picker" />
<span class="range-separator">-</span>
<el-date-picker v-model="endDate"
type="date"
value-format="yyyy-MM-dd"
format="yyyy/MM/dd"
placeholder="结束日期"
:disabled="disabled || !targetMonth" :disabled="disabled || !targetMonth"
:picker-options="periodPickerOptions" :picker-options="endPickerOptions"
class="period-picker" class="period-picker end-picker"
@change="handleRangeChange" /> @change="handleEndChange" />
<el-checkbox v-model="isFullMonth" <el-checkbox v-model="isFullMonth"
:disabled="disabled || !targetMonth" :disabled="disabled || !targetMonth"
class="full-month-check" class="full-month-check"
...@@ -42,53 +48,50 @@ export default { ...@@ -42,53 +48,50 @@ export default {
}, },
data() { data() {
return { return {
innerRange: [], endDate: '',
isFullMonth: false, isFullMonth: false,
rangePickAnchor: null endPickerOptions: {
disabledDate: (time) => this.isEndDateDisabled(time)
}
} }
}, },
computed: { computed: {
periodPickerOptions() { startDate() {
const monthRange = getMonthDateRange(this.targetMonth) const { startDate } = getMonthDateRange(this.targetMonth) || {}
return { return startDate || ''
onPick: ({ minDate, maxDate }) => {
if (maxDate) {
this.rangePickAnchor = null
} else if (minDate) {
this.rangePickAnchor = minDate
}
},
disabledDate: (time) => {
if (!monthRange) return true
const { startDate, endDate } = monthRange
const timeStr = this.formatDateStr(time)
if (timeStr < startDate || timeStr > endDate) return true
if (!this.rangePickAnchor) {
return timeStr !== startDate
}
return timeStr < startDate || timeStr > endDate
}
}
} }
}, },
watch: { watch: {
value: { value: {
immediate: true, immediate: true,
handler(val) { handler(val) {
this.innerRange = val && val.length ? [...val] : [] if (val && val.length === 2 && val[1]) {
this.endDate = val[1]
} else {
this.endDate = ''
}
this.syncFullMonthState() this.syncFullMonthState()
} }
}, },
targetMonth(val, oldVal) { targetMonth(val, oldVal) {
if (val !== oldVal) { if (val !== oldVal && oldVal) {
this.rangePickAnchor = null this.resetRangeState()
this.innerRange = []
this.isFullMonth = false
this.emitChange([])
} }
} }
}, },
methods: { methods: {
isEndDateDisabled(time) {
const monthRange = getMonthDateRange(this.targetMonth)
if (!monthRange) return true
const { startDate, endDate } = monthRange
const timeStr = this.formatDateStr(time)
return timeStr < startDate || timeStr > endDate
},
resetRangeState() {
this.endDate = ''
this.isFullMonth = false
this.emitChange([])
},
formatDateStr(time) { formatDateStr(time) {
const y = time.getFullYear() const y = time.getFullYear()
const m = String(time.getMonth() + 1).padStart(2, '0') const m = String(time.getMonth() + 1).padStart(2, '0')
...@@ -96,47 +99,35 @@ export default { ...@@ -96,47 +99,35 @@ export default {
return `${y}-${m}-${d}` return `${y}-${m}-${d}`
}, },
syncFullMonthState() { syncFullMonthState() {
if (!this.targetMonth || !this.innerRange || this.innerRange.length !== 2) { if (!this.targetMonth || !this.endDate || !this.startDate) {
this.isFullMonth = false this.isFullMonth = false
return return
} }
const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {} const { endDate } = getMonthDateRange(this.targetMonth) || {}
this.isFullMonth = this.innerRange[0] === startDate && this.innerRange[1] === endDate this.isFullMonth = this.endDate === endDate
},
normalizeRange(range) {
if (!range || range.length !== 2 || !this.targetMonth) return []
const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {}
if (!startDate || !endDate) return []
let end = range[1]
if (end < startDate) end = startDate
if (end > endDate) end = endDate
return [startDate, end]
}, },
emitChange(range) { emitChange(range) {
this.$emit('input', range) this.$emit('input', range)
this.$emit('change', range) this.$emit('change', range)
}, },
handleRangeChange(val) { handleEndChange(val) {
this.rangePickAnchor = null if (!val || !this.startDate) {
if (!val || val.length !== 2) {
this.isFullMonth = false this.isFullMonth = false
this.emitChange([]) this.emitChange([])
return return
} }
const normalized = this.normalizeRange(val)
this.innerRange = normalized
this.syncFullMonthState() this.syncFullMonthState()
this.emitChange(normalized) this.emitChange([this.startDate, val])
}, },
handleFullMonthChange(checked) { handleFullMonthChange(checked) {
if (checked) { if (checked) {
const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {} const { startDate, endDate } = getMonthDateRange(this.targetMonth) || {}
if (startDate && endDate) { if (startDate && endDate) {
this.innerRange = [startDate, endDate] this.endDate = endDate
this.emitChange([startDate, endDate]) this.emitChange([startDate, endDate])
} }
} else { } else {
this.innerRange = [] this.endDate = ''
this.emitChange([]) this.emitChange([])
} }
} }
...@@ -152,6 +143,16 @@ export default { ...@@ -152,6 +143,16 @@ export default {
.period-picker { .period-picker {
flex: 1; flex: 1;
} }
.start-picker {
max-width: 46%;
}
.end-picker {
max-width: 46%;
}
.range-separator {
margin: 0 4px;
color: #606266;
}
.full-month-check { .full-month-check {
margin-left: 10px; margin-left: 10px;
white-space: nowrap; white-space: nowrap;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!