Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 23b4193f
authored
Jul 10, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 添加结算日期选择功能及相关逻辑
1 parent
3a00a5de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
14 deletions
src/common/format.js
src/views/systemConfig/ShopConfig/deliveryQuantity/components/periodDateRange.vue
src/views/systemConfig/ShopConfig/deliveryQuantity/deliveryPeriod.spec.js
src/views/systemConfig/ShopConfig/deliveryQuantity/index.vue
src/common/format.js
View file @
23b4193
...
@@ -490,6 +490,49 @@ export function getMonthDateRange(targetMonth) {
...
@@ -490,6 +490,49 @@ export function getMonthDateRange(targetMonth) {
return
{
startDate
,
endDate
};
return
{
startDate
,
endDate
};
}
}
export
function
getFallbackSettlementOptions
()
{
const
options
=
[{
label
:
"每月最后1天"
,
value
:
0
}];
for
(
let
day
=
1
;
day
<=
27
;
day
+=
1
)
{
options
.
push
({
label
:
`每月
${
day
}
号`
,
value
:
day
});
}
return
options
;
}
export
function
getSettlementPeriodRange
(
targetMonth
,
settlementDate
=
0
)
{
const
monthRange
=
getMonthDateRange
(
targetMonth
);
if
(
!
monthRange
)
return
null
;
const
day
=
Number
(
settlementDate
)
||
0
;
if
(
day
<=
0
)
{
return
{
startDate
:
monthRange
.
startDate
,
fullEndDate
:
monthRange
.
endDate
,
maxEndDate
:
monthRange
.
endDate
,
};
}
const
[
yearStr
,
monthStr
]
=
targetMonth
.
split
(
"-"
);
const
year
=
parseInt
(
yearStr
,
10
);
const
month
=
parseInt
(
monthStr
,
10
);
const
start
=
new
Date
(
year
,
month
-
2
,
day
+
1
);
const
startDate
=
`
${
start
.
getFullYear
()}
-
${
String
(
start
.
getMonth
()
+
1
).
padStart
(
2
,
"0"
)}
-
${
String
(
start
.
getDate
()).
padStart
(
2
,
"0"
)}
`
;
const
fullEndDate
=
`
${
yearStr
}
-
${
monthStr
.
padStart
(
2
,
"0"
)}
-
${
String
(
day
).
padStart
(
2
,
"0"
)}
`
;
return
{
startDate
,
fullEndDate
,
maxEndDate
:
fullEndDate
,
};
}
export
function
getSettlementPeriodPickerDefaultDate
(
targetMonth
,
settlementDate
=
0
)
{
const
{
maxEndDate
}
=
getSettlementPeriodRange
(
targetMonth
,
settlementDate
)
||
{};
if
(
!
maxEndDate
)
return
null
;
const
[
year
,
month
,
day
]
=
maxEndDate
.
split
(
"-"
).
map
(
item
=>
parseInt
(
item
,
10
));
return
new
Date
(
year
,
month
-
1
,
day
);
}
/**
/**
* 解析归属周期展示字符串为 [startDate, endDate]
* 解析归属周期展示字符串为 [startDate, endDate]
* 支持 2026/05/01-2026/05/15 与 2026-05-01-2026-05-15
* 支持 2026/05/01-2026/05/15 与 2026-05-01-2026-05-15
...
...
src/views/systemConfig/ShopConfig/deliveryQuantity/components/periodDateRange.vue
View file @
23b4193
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
value-format=
"yyyy-MM-dd"
value-format=
"yyyy-MM-dd"
format=
"yyyy/MM/dd"
format=
"yyyy/MM/dd"
placeholder=
"结束日期"
placeholder=
"结束日期"
:default-value=
"endPickerDefaultValue"
:disabled=
"disabled || !targetMonth"
:disabled=
"disabled || !targetMonth"
:picker-options=
"endPickerOptions"
:picker-options=
"endPickerOptions"
class=
"period-picker end-picker"
class=
"period-picker end-picker"
...
@@ -28,7 +29,7 @@
...
@@ -28,7 +29,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
get
MonthDate
Range
}
from
'@/common/format'
import
{
get
SettlementPeriodPickerDefaultDate
,
getSettlementPeriod
Range
}
from
'@/common/format'
export
default
{
export
default
{
name
:
'PeriodDateRange'
,
name
:
'PeriodDateRange'
,
...
@@ -41,6 +42,10 @@ export default {
...
@@ -41,6 +42,10 @@ export default {
type
:
String
,
type
:
String
,
default
:
''
default
:
''
},
},
settlementDate
:
{
type
:
[
Number
,
String
],
default
:
0
},
disabled
:
{
disabled
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
false
default
:
false
...
@@ -56,9 +61,14 @@ export default {
...
@@ -56,9 +61,14 @@ export default {
}
}
},
},
computed
:
{
computed
:
{
periodRangeLimit
()
{
return
getSettlementPeriodRange
(
this
.
targetMonth
,
this
.
settlementDate
)
||
{}
},
startDate
()
{
startDate
()
{
const
{
startDate
}
=
getMonthDateRange
(
this
.
targetMonth
)
||
{}
return
this
.
periodRangeLimit
.
startDate
||
''
return
startDate
||
''
},
endPickerDefaultValue
()
{
return
getSettlementPeriodPickerDefaultDate
(
this
.
targetMonth
,
this
.
settlementDate
)
}
}
},
},
watch
:
{
watch
:
{
...
@@ -77,15 +87,19 @@ export default {
...
@@ -77,15 +87,19 @@ export default {
if
(
val
!==
oldVal
&&
oldVal
)
{
if
(
val
!==
oldVal
&&
oldVal
)
{
this
.
resetRangeState
()
this
.
resetRangeState
()
}
}
},
settlementDate
(
val
,
oldVal
)
{
if
(
val
!==
oldVal
)
{
this
.
resetRangeState
()
}
}
}
},
},
methods
:
{
methods
:
{
isEndDateDisabled
(
time
)
{
isEndDateDisabled
(
time
)
{
const
monthRange
=
getMonthDateRange
(
this
.
targetMonth
)
const
{
startDate
,
maxEndDate
}
=
this
.
periodRangeLimit
if
(
!
monthRange
)
return
true
if
(
!
startDate
||
!
maxEndDate
)
return
true
const
{
startDate
,
endDate
}
=
monthRange
const
timeStr
=
this
.
formatDateStr
(
time
)
const
timeStr
=
this
.
formatDateStr
(
time
)
return
timeStr
<
startDate
||
timeStr
>
e
ndDate
return
timeStr
<
startDate
||
timeStr
>
maxE
ndDate
},
},
resetRangeState
()
{
resetRangeState
()
{
this
.
endDate
=
''
this
.
endDate
=
''
...
@@ -103,8 +117,8 @@ export default {
...
@@ -103,8 +117,8 @@ export default {
this
.
isFullMonth
=
false
this
.
isFullMonth
=
false
return
return
}
}
const
{
endDate
}
=
getMonthDateRange
(
this
.
targetMonth
)
||
{}
const
{
fullEndDate
}
=
this
.
periodRangeLimit
this
.
isFullMonth
=
this
.
endDate
===
e
ndDate
this
.
isFullMonth
=
this
.
endDate
===
fullE
ndDate
},
},
emitChange
(
range
)
{
emitChange
(
range
)
{
this
.
$emit
(
'input'
,
range
)
this
.
$emit
(
'input'
,
range
)
...
@@ -121,10 +135,10 @@ export default {
...
@@ -121,10 +135,10 @@ export default {
},
},
handleFullMonthChange
(
checked
)
{
handleFullMonthChange
(
checked
)
{
if
(
checked
)
{
if
(
checked
)
{
const
{
startDate
,
endDate
}
=
getMonthDateRange
(
this
.
targetMonth
)
||
{}
const
{
startDate
,
fullEndDate
}
=
this
.
periodRangeLimit
if
(
startDate
&&
e
ndDate
)
{
if
(
startDate
&&
fullE
ndDate
)
{
this
.
endDate
=
e
ndDate
this
.
endDate
=
fullE
ndDate
this
.
emitChange
([
startDate
,
e
ndDate
])
this
.
emitChange
([
startDate
,
fullE
ndDate
])
}
}
}
else
{
}
else
{
this
.
endDate
=
''
this
.
endDate
=
''
...
...
src/views/systemConfig/ShopConfig/deliveryQuantity/deliveryPeriod.spec.js
0 → 100644
View file @
23b4193
import
{
getFallbackSettlementOptions
,
getSettlementPeriodPickerDefaultDate
,
getSettlementPeriodRange
}
from
"@/common/format"
;
describe
(
"delivery quantity settlement period"
,
()
=>
{
it
(
"builds last-day and 1-27 fallback settlement options"
,
()
=>
{
const
options
=
getFallbackSettlementOptions
();
expect
(
options
).
toHaveLength
(
28
);
expect
(
options
[
0
]).
toEqual
({
label
:
"每月最后1天"
,
value
:
0
});
expect
(
options
[
1
]).
toEqual
({
label
:
"每月1号"
,
value
:
1
});
expect
(
options
[
27
]).
toEqual
({
label
:
"每月27号"
,
value
:
27
});
});
it
(
"uses natural month range when fallback settlement day is the last day"
,
()
=>
{
expect
(
getSettlementPeriodRange
(
"2026-05"
,
0
)).
toEqual
({
startDate
:
"2026-05-01"
,
fullEndDate
:
"2026-05-31"
,
maxEndDate
:
"2026-05-31"
,
});
});
it
(
"uses previous-month next day through selected day for full period"
,
()
=>
{
expect
(
getSettlementPeriodRange
(
"2026-05"
,
25
)).
toEqual
({
startDate
:
"2026-04-26"
,
fullEndDate
:
"2026-05-25"
,
maxEndDate
:
"2026-05-25"
,
});
});
it
(
"opens end date picker on target month instead of current month"
,
()
=>
{
const
defaultDate
=
getSettlementPeriodPickerDefaultDate
(
"2026-06"
,
25
);
expect
(
defaultDate
).
toEqual
(
new
Date
(
2026
,
5
,
25
));
});
});
src/views/systemConfig/ShopConfig/deliveryQuantity/index.vue
View file @
23b4193
...
@@ -108,9 +108,22 @@
...
@@ -108,9 +108,22 @@
:picker-options=
"importMonthPickerOption"
:picker-options=
"importMonthPickerOption"
@
change=
"handleImportTargetMonthChange"
/>
@
change=
"handleImportTargetMonthChange"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"兜底结算日期:"
required
>
<el-select
v-model=
"importForm.settlementDate"
placeholder=
"请选择"
style=
"width: 100%;"
@
change=
"handleImportFallbackSettlementDayChange"
>
<el-option
v-for=
"item in fallbackSettlementOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"归属周期:"
<el-form-item
label=
"归属周期:"
required
>
required
>
<PeriodDateRange
v-model=
"importForm.periodRange"
<PeriodDateRange
v-model=
"importForm.periodRange"
:settlement-date=
"importForm.settlementDate"
:target-month=
"importForm.targetMonth"
/>
:target-month=
"importForm.targetMonth"
/>
</el-form-item>
</el-form-item>
</
template
>
</
template
>
...
@@ -128,7 +141,7 @@
...
@@ -128,7 +141,7 @@
import
{
getList
}
from
"@api/merchant"
;
import
{
getList
}
from
"@api/merchant"
;
import
{
deleteById_deliver
,
deliverTargeConfigImport
,
distinctAllBrand
,
listWithPage_deliver
}
from
"@api/shopConfig"
;
import
{
deleteById_deliver
,
deliverTargeConfigImport
,
distinctAllBrand
,
listWithPage_deliver
}
from
"@api/shopConfig"
;
import
{
mapActions
,
mapState
}
from
"vuex"
;
import
{
mapActions
,
mapState
}
from
"vuex"
;
import
{
rangePickerOptions_deliveryQuantity_import
}
from
"@/common/format"
;
import
{
getFallbackSettlementOptions
,
getSettlementPeriodRange
,
rangePickerOptions_deliveryQuantity_import
}
from
"@/common/format"
;
import
{
deepClone
,
Util
}
from
"@/common/util"
;
import
{
deepClone
,
Util
}
from
"@/common/util"
;
import
reportTrackFunMixin
from
"@/mixins/reportTrackFunMixin"
;
import
reportTrackFunMixin
from
"@/mixins/reportTrackFunMixin"
;
import
editDialog
from
"./components/editDialog"
;
import
editDialog
from
"./components/editDialog"
;
...
@@ -269,8 +282,10 @@ export default {
...
@@ -269,8 +282,10 @@ export default {
importMonthPickerOption
:
rangePickerOptions_deliveryQuantity_import
,
importMonthPickerOption
:
rangePickerOptions_deliveryQuantity_import
,
importForm
:
{
importForm
:
{
targetMonth
:
""
,
targetMonth
:
""
,
settlementDate
:
0
,
periodRange
:
[],
periodRange
:
[],
},
},
fallbackSettlementOptions
:
getFallbackSettlementOptions
(),
track_event_code
:
"shopConfig_deliver_list"
,
track_event_code
:
"shopConfig_deliver_list"
,
track_businessParam_key
:
"searchForm"
,
track_businessParam_key
:
"searchForm"
,
};
};
...
@@ -485,6 +500,7 @@ export default {
...
@@ -485,6 +500,7 @@ export default {
resetImportForm
()
{
resetImportForm
()
{
this
.
importForm
=
{
this
.
importForm
=
{
targetMonth
:
""
,
targetMonth
:
""
,
settlementDate
:
0
,
periodRange
:
[],
periodRange
:
[],
};
};
},
},
...
@@ -493,16 +509,29 @@ export default {
...
@@ -493,16 +509,29 @@ export default {
this
.
importForm
.
periodRange
=
[];
this
.
importForm
.
periodRange
=
[];
},
},
handleImportFallbackSettlementDayChange
()
{
this
.
importForm
.
periodRange
=
[];
},
validateImportForm
()
{
validateImportForm
()
{
if
(
!
this
.
importForm
.
targetMonth
)
{
if
(
!
this
.
importForm
.
targetMonth
)
{
this
.
notice
.
warningTips
(
"请选择交付目标月份"
);
this
.
notice
.
warningTips
(
"请选择交付目标月份"
);
return
false
;
return
false
;
}
}
if
(
this
.
importForm
.
settlementDate
===
""
||
this
.
importForm
.
settlementDate
===
null
||
this
.
importForm
.
settlementDate
===
undefined
)
{
this
.
notice
.
warningTips
(
"请选择兜底结算日期"
);
return
false
;
}
const
{
periodRange
}
=
this
.
importForm
;
const
{
periodRange
}
=
this
.
importForm
;
if
(
!
periodRange
||
periodRange
.
length
!==
2
||
!
periodRange
[
0
]
||
!
periodRange
[
1
])
{
if
(
!
periodRange
||
periodRange
.
length
!==
2
||
!
periodRange
[
0
]
||
!
periodRange
[
1
])
{
this
.
notice
.
warningTips
(
"请选择归属周期"
);
this
.
notice
.
warningTips
(
"请选择归属周期"
);
return
false
;
return
false
;
}
}
const
monthRange
=
getSettlementPeriodRange
(
this
.
importForm
.
targetMonth
,
this
.
importForm
.
settlementDate
);
if
(
!
monthRange
||
periodRange
[
0
]
!==
monthRange
.
startDate
||
periodRange
[
1
]
<
periodRange
[
0
]
||
periodRange
[
1
]
>
monthRange
.
maxEndDate
)
{
this
.
notice
.
warningTips
(
"归属周期日期无效"
);
return
false
;
}
return
true
;
return
true
;
},
},
...
@@ -513,6 +542,7 @@ export default {
...
@@ -513,6 +542,7 @@ export default {
let
params
=
{
let
params
=
{
file
:
fileData
,
file
:
fileData
,
targetMonth
:
this
.
importForm
.
targetMonth
,
targetMonth
:
this
.
importForm
.
targetMonth
,
settlementDate
:
this
.
importForm
.
settlementDate
,
periodStartDate
:
this
.
importForm
.
periodRange
[
0
],
periodStartDate
:
this
.
importForm
.
periodRange
[
0
],
periodEndDate
:
this
.
importForm
.
periodRange
[
1
],
periodEndDate
:
this
.
importForm
.
periodRange
[
1
],
};
};
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment