Commit 305fb80c by 张立顺

feat 联调修改

1 parent 320185b6
...@@ -496,22 +496,6 @@ export function getMonthDateRange(targetMonth) { ...@@ -496,22 +496,6 @@ export function getMonthDateRange(targetMonth) {
} }
/** /**
* 构建交付数归属周期日期选择器的 disabledDate
* @param {string} targetMonth yyyy-MM
*/
export function buildPeriodDatePickerOptions(targetMonth) {
return {
disabledDate: (time) => {
if (!targetMonth) return true;
const [yearStr, monthStr] = targetMonth.split("-");
const year = parseInt(yearStr, 10);
const month = parseInt(monthStr, 10) - 1;
return time.getFullYear() !== year || time.getMonth() !== month;
},
};
}
/**
* 店面配置-门店主机厂交付数导入 * 店面配置-门店主机厂交付数导入
* 限制:当前日期>20号:仅允许选择当前月份;当前日期≤20号:允许选择当前月份和上个月 * 限制:当前日期>20号:仅允许选择当前月份;当前日期≤20号:允许选择当前月份和上个月
*/ */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</template> </template>
<script> <script>
import { getMonthDateRange, buildPeriodDatePickerOptions } from '@/common/format' import { getMonthDateRange } from '@/common/format'
export default { export default {
name: 'PeriodDateRange', name: 'PeriodDateRange',
...@@ -44,7 +44,31 @@ export default { ...@@ -44,7 +44,31 @@ export default {
return { return {
innerRange: [], innerRange: [],
isFullMonth: false, isFullMonth: false,
periodPickerOptions: buildPeriodDatePickerOptions('') rangePickAnchor: null
}
},
computed: {
periodPickerOptions() {
const monthRange = getMonthDateRange(this.targetMonth)
return {
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: {
...@@ -56,8 +80,8 @@ export default { ...@@ -56,8 +80,8 @@ export default {
} }
}, },
targetMonth(val, oldVal) { targetMonth(val, oldVal) {
this.periodPickerOptions = buildPeriodDatePickerOptions(val)
if (val !== oldVal) { if (val !== oldVal) {
this.rangePickAnchor = null
this.innerRange = [] this.innerRange = []
this.isFullMonth = false this.isFullMonth = false
this.emitChange([]) this.emitChange([])
...@@ -65,6 +89,12 @@ export default { ...@@ -65,6 +89,12 @@ export default {
} }
}, },
methods: { methods: {
formatDateStr(time) {
const y = time.getFullYear()
const m = String(time.getMonth() + 1).padStart(2, '0')
const d = String(time.getDate()).padStart(2, '0')
return `${y}-${m}-${d}`
},
syncFullMonthState() { syncFullMonthState() {
if (!this.targetMonth || !this.innerRange || this.innerRange.length !== 2) { if (!this.targetMonth || !this.innerRange || this.innerRange.length !== 2) {
this.isFullMonth = false this.isFullMonth = false
...@@ -87,6 +117,7 @@ export default { ...@@ -87,6 +117,7 @@ export default {
this.$emit('change', range) this.$emit('change', range)
}, },
handleRangeChange(val) { handleRangeChange(val) {
this.rangePickAnchor = null
if (!val || val.length !== 2) { if (!val || val.length !== 2) {
this.isFullMonth = false this.isFullMonth = false
this.emitChange([]) this.emitChange([])
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!